제출 #105911

#제출 시각아이디문제언어결과실행 시간메모리
105911nvmdava마상시합 토너먼트 (IOI12_tournament)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define N 131075 int n; int r[N]; int lef[N][20]; int logg[N]; void fillsparse(){ for(int i = 1; i <= n; i++){ lef[i][0] = r[i]; for(int j = 1; j < 20; j++){ if(i < (1 << j)) break; lef[i][j] = max(lef[i][j - 1], lef[i - (1 << (j - 1))][j - 1]); } } logg[1] = 0; for(int i = 2; i <= 131072; i++) logg[i] = logg[i / 2] + 1; } int getmin(int l, int r){ int sz = logg[r - l + 1]; return max(lef[r][sz], lef[l + (1 << sz) - 1][sz]); } struct Fen{ int arr[N]; void update(int id, int val){ for(; id < N; id += id & -id) arr[id] += val; }; int sum(int id){ int res = 0; while(id){ res += arr[id]; id -= id & -id; } return res; } } fen; int segTree[2 * N]; #define MX 131072 void update(int id, int l, int r, int L, int R){ if(l == L && r == R){ segTree[id]++; return; } int m = (l + r) >> 1; if(m < L) update(id << 1 | 1, m + 1, r, L, R); else if(m >= R) update(id << 1, l, m, L, R); else { update(id << 1, l, m, L, m); update(id << 1 | 1, m + 1, r, m + 1, R); } } typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; ordered_set pos; int GetBestPosition(int NN, int C, int R, int *K, int *S, int *E) { n = NN; pos.insert({0, 0}); for(int i = 1; i < n; i++){ r[i] = S[i - 1]; pos.insert({i, i}); } pos.insert({n, n}); r[n] = -1; fillsparse(); // cout<<'\n'; for(int i = 0; i < C; i++){ int add1 = 0, add2 = 0; S[i]++; E[i]++; int lst = (*pos.find_by_order(E[i])).second; int beg = (*pos.find_by_order(S[i])).first; for(; E[i] >= S[i]; E[i]--){ pos.erase(pos.find_by_order(E[i])); } E[i] = lst; S[i] = beg; pos.insert({beg, lst}); // cout<<S[i]<<' '<<E[i]<<'\n'; if(getmin(S[i], E[i] - 1) < R){ update(1, 1, MX, S[i], E[i]); } } // cout<<'\n'; for(int i = 1; i < MX; i++){ segTree[i << 1] += segTree[i]; segTree[i << 1 | 1] += segTree[i]; } int best = 0; for(int i = 1; i < n; i++){ if(segTree[MX + i] > segTree[MX + best]){ best = i; } } /* for(int i = 0; i < n; i++){ cout<<i<<' '<<segTree[i + MX]<<'\n'; } */ return best; } /* #define inbuf_len 1 << 16 #define outbuf_len 1 << 16 int GetBestPosition(int NN, int C, int R, int *K, int *S, int *E); int main() { int tmp; /* Set input and output buffering */ char *inbuf, *outbuf; inbuf = (char*) malloc(inbuf_len * sizeof(char)); outbuf = (char*) malloc(outbuf_len * sizeof(char)); int NN, C, R; int *K, *S, *E; tmp = scanf("%d %d %d", &NN, &C, &R); K = (int*) malloc((NN-1) * sizeof(int)); S = (int*) malloc(C * sizeof(int)); E = (int*) malloc(C * sizeof(int)); int i; for (i = 0; i < NN-1; i++) { tmp = scanf("%d", &K[i]); assert(tmp == 1); } for (i = 0; i < C; i++) { tmp = scanf("%d %d", &S[i], &E[i]); assert(tmp == 2); } printf("\n%d\n", GetBestPosition(NN, C, R, K, S, E)); return 0; } */

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

tournament.cpp:125:3: warning: "/*" within comment [-Wcomment]
   /* Set input and output buffering */
    
tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:79:13: warning: unused variable 'add1' [-Wunused-variable]
         int add1 = 0, add2 = 0;
             ^~~~
tournament.cpp:79:23: warning: unused variable 'add2' [-Wunused-variable]
         int add1 = 0, add2 = 0;
                       ^~~~
tournament.cpp: At global scope:
tournament.cpp:127:3: error: 'inbuf' does not name a type
   inbuf = (char*) malloc(inbuf_len * sizeof(char));
   ^~~~~
tournament.cpp:128:3: error: 'outbuf' does not name a type
   outbuf = (char*) malloc(outbuf_len * sizeof(char));
   ^~~~~~
tournament.cpp:131:3: error: 'tmp' does not name a type; did you mean 'tm'?
   tmp = scanf("%d %d %d", &NN, &C, &R);
   ^~~
   tm
tournament.cpp:132:3: error: 'K' does not name a type
   K = (int*) malloc((NN-1) * sizeof(int));
   ^
tournament.cpp:133:3: error: 'S' does not name a type
   S = (int*) malloc(C * sizeof(int));
   ^
tournament.cpp:134:3: error: 'E' does not name a type
   E = (int*) malloc(C * sizeof(int));
   ^
tournament.cpp:136:3: error: expected unqualified-id before 'for'
   for (i = 0; i < NN-1; i++) {
   ^~~
tournament.cpp:136:15: error: 'i' does not name a type
   for (i = 0; i < NN-1; i++) {
               ^
tournament.cpp:136:25: error: 'i' does not name a type
   for (i = 0; i < NN-1; i++) {
                         ^
tournament.cpp:140:3: error: expected unqualified-id before 'for'
   for (i = 0; i < C; i++) {
   ^~~
tournament.cpp:140:15: error: 'i' does not name a type
   for (i = 0; i < C; i++) {
               ^
tournament.cpp:140:22: error: 'i' does not name a type
   for (i = 0; i < C; i++) {
                      ^
tournament.cpp:145:9: error: expected constructor, destructor, or type conversion before '(' token
   printf("\n%d\n", GetBestPosition(NN, C, R, K, S, E));
         ^
tournament.cpp:147:3: error: expected unqualified-id before 'return'
   return 0;
   ^~~~~~
tournament.cpp:149:1: error: expected declaration before '}' token
 }
 ^