제출 #830209

#제출 시각아이디문제언어결과실행 시간메모리
830209Liudas마상시합 토너먼트 (IOI12_tournament)C++17
컴파일 에러
0 ms0 KiB
//#include <stdio.h> //#include <stdlib.h> //#include <assert.h> #include <vector> #include <algorithm> #include <iostream> #include <fstream> #include "tournament.h" using namespace std; vector<int> tree, alive; int N; void init(int K){ N = 1; while(N <= K){ N *= 2; } tree.assign(N * 2, 0); alive.assign(N * 2, 0); } void add_alive(int head, int l, int r, int pos, int val){ if(r - l == 1){ alive[head] = val; return; } int mid = (l + r) / 2; if(pos < mid){ add_alive(head * 2 + 1, l, mid, pos, val); } else{ add_alive(head * 2 + 2, mid, r, pos, val); } alive[head] = alive[head * 2 + 1] + alive[head * 2 + 2]; } void add_alive(int pos, int val){ add_alive(0, 0, N, pos, val); } int get_alive(int head, int l, int r, int need, int left){ //cout << l << " " << r << " " << need << " " << alive[head] + left << endl; if(r - l == 1){ return l; } int mid = (l + r) / 2; if(need <= alive[head * 2 + 1] + left){ return get_alive(head * 2 + 1, l, mid, need, left); } else{ return get_alive(head * 2 + 2, mid, r, need, left + alive[head * 2 + 1]); } } int get_alive(int need){ return get_alive(0, 0, N, need, 0); } void add_val(int head, int l, int r, int pos, int val){ if(r - l == 1){ tree[head] = val; return; } int mid = (l + r) / 2; if(pos < mid){ add_val(head * 2 + 1, l, mid, pos, val); } else{ add_val(head * 2 + 2, mid, r, pos, val); } tree[head] = max(tree[head * 2 + 1], tree[head * 2 + 2]); } void add_val(int pos, int val){ add_val(0, 0, N, pos, val); } int get_val(int head, int l, int r, int L, int R){ if(L <= l && R >= r){ return tree[head]; } if(L >= r || R <= l){ return 0; } int mid = (l + r) / 2; return max(get_val(head * 2 + 1, l, mid, L, R), get_val(head * 2 + 2, mid, r, L, R)); } int get_val(int l, int r){ return get_val(0, 0, N, l, r); } clock_t startTime; double getCurrentTime() { return (double)(clock() - startTime) / CLOCKS_PER_SEC; } int GetBestPosition(int N, int C, int R, int K[], int S[], int E[]){ startTime = getCurrentTime(); init(N); vector<int> pref(N + 5); int ans = 0; int id = 0; for(int i = 0; i < N; i ++){ for(int j = 0; j < N; j ++){ add_val(j+(j >= i), K[j]); add_alive(j, 1); } add_val(i, R); add_alive(N, 1); for(int j = 0; j < C; j ++){ int s = get_alive(S[j] + 1), e = get_alive(E[j] + 2); if(get_val(s, e) == R){ pref[s] ++; pref[e + 1]--; } for(int k = S[j]; k < E[j]; k ++){ add_alive(get_alive(S[j] + 2), 0); } } int p = 0; for(int j = 0; j < N; j ++){ p += pref[j]; pref[j] = 0; if(ans < p){ ans = p; id = j; } } } cout << getCurrentTime() - startTime << endl; return id; }

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

tournament.cpp:8:10: fatal error: tournament.h: No such file or directory
    8 | #include "tournament.h"
      |          ^~~~~~~~~~~~~~
compilation terminated.