제출 #105882

#제출 시각아이디문제언어결과실행 시간메모리
105882nvmdava마상시합 토너먼트 (IOI12_tournament)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #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; } } } Fen 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); } } int GetBestPosition(int NN, int C, int R, int *K, int *S, int *E) { n = NN; for(int i = 1; i < n; i++){ r[i] = S[i - 1]; } r[n] = -1; fillsparse(); for(int i = 0; i < C; i++){ int add1, add2; S[i]++; E[i]++; add1 = fen.sum(S[i]); add2 = fen.sum(E[i]); fen.upd(S[i], E[i] - S[i]); S[i] += add1; E[i] += add2; if(getmin(S[i], E[i] - 1) < R){ update(1, 1, MX, S[i], E[i]); } } 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; } } return best; }

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

tournament.cpp: In member function 'int Fen::sum(int)':
tournament.cpp:42:5: warning: no return statement in function returning non-void [-Wreturn-type]
     }
     ^
tournament.cpp: At global scope:
tournament.cpp:45:5: error: expected initializer before 'fen'
 Fen fen;
     ^~~
tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:76:16: error: 'fen' was not declared in this scope
         add1 = fen.sum(S[i]);
                ^~~
tournament.cpp:76:16: note: suggested alternative: 'Fen'
         add1 = fen.sum(S[i]);
                ^~~
                Fen