pku 2299Ultra-QuickSort(归并排序求逆序数)
摘要:1 /* 2 * 归并排序求逆序对 3 */ 4 5 #include <cstdio> 6 #include <iostream> 7 8 using namespace std; 9 10 const int N = 500005;11 12 long long ans;13 int a[N], b[N];14 15 void mergeSort(int left, int right) {16 int i, j, k, mid;17 if (left < right) {18 mid = (left + right) >> 1;19 ...
阅读全文
posted @
2012-05-16 20:51
Try86
阅读(155)
推荐(0)
RQNOJ 173(归并排序求逆序数)
摘要:1 /* 2 * 归并排序求逆序对 3 */ 4 5 #include <cstdio> 6 #include <iostream> 7 8 using namespace std; 9 10 const int N = 20005;11 12 long long ans;13 int a[N], b[N];14 15 void mergeSort(int left, int right) {16 int i, j, k, mid;17 if (left < right) {18 mid = (left + right) >> 1;19 ...
阅读全文
posted @
2012-05-14 22:51
Try86
阅读(158)
推荐(0)
hdu 2141(排序+二分)
摘要:1 /* 2 * 排序+二分 3 */ 4 5 #include <stdio.h> 6 #include <stdlib.h> 7 #define N 501 8 9 int a[N], b[N*N], c[N];10 11 int cmp(const void *a, const void *b) {12 return *(int *)a - *(int *)b;13 }14 15 int main() {16 int l, n, m, s, i, j, k, tmp, tmpp, left, right, mid, flag, cas = 0;17 wh...
阅读全文
posted @
2012-05-05 22:52
Try86
阅读(214)
推荐(0)
hdu 1004(排序+统计)
摘要://排序+统计#include <cstdio>#include <cstring>#include <iostream>using namespace std;char str[1000][16];int cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b);}int solve(int n) { char temp[16]; int i, c, maxs, mi; qsort(str, n, sizeof(str[0]), cmp); strcpy(temp, st
阅读全文
posted @
2012-04-03 20:40
Try86
阅读(157)
推荐(0)