제출 #362081

#제출 시각아이디문제언어결과실행 시간메모리
362081idk321마상시합 토너먼트 (IOI12_tournament)C++11
0 / 100
366 ms2044 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5005; int tree[4 * N]; void make(int i, int num, int a, int b, int node) { if (a == b) { tree[node] = num; return; } int mid = (a + b) / 2; if (i <= mid) make(i, num, a, mid, node * 2); else make(i, num, mid + 1, b, node * 2 + 1); tree[node] = tree[node * 2] + tree[node * 2 + 1]; } int kth(int k, int a, int b, int node) { if (a == b) return a; int mid = (a + b) / 2; if (tree[node * 2] > k) return kth(k, a, mid, node * 2); return kth(k - tree[node * 2], mid + 1, b, node * 2 + 1); } int GetBestPosition(int n, int c, int r, int *k, int *s, int *e) { int best = -1; int pos = -1; //cout << endl; for (int i = 0; i < n; i++) { vector<int> nr(n); nr[i] = r; for (int j = 0; j < n - 1; j++) { if (j < i) nr[j] = k[j]; else nr[j + 1] = k[j]; } for (int i = 0; i < n; i++) make(i, 1, 0, n - 1, 1); int cur = 0; for (int j = 0; j < c; j++) { int ci = -1; int cbest = -1; for (int l = s[j]; l <= e[j]; l++) { int ki = kth(s[j], 0, n - 1, 1); if (nr[ki] > cbest) { cbest = nr[ki]; ci = ki; } make(ki, 0, 0, n - 1, 1); } make(ci, 1, 0, n - 1, 1); //cout << i << " " << cbest << endl; if (cbest == r) cur++; } if (cur > best) { best = cur; pos = i; } } return best; } /* 5 3 2 1 0 4 3 0 1 0 1 1 3 */

컴파일 시 표준 에러 (stderr) 메시지

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:36:9: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
   36 |     int pos = -1;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...