Submission #242222

#TimeUsernameProblemLanguageResultExecution timeMemory
242222dantoh000Jousting tournament (IOI12_tournament)C++14
17 / 100
58 ms1536 KiB
#include <bits/stdc++.h> using namespace std; int l[5005], r[5005], RR[5005]; int in[5005]; int id[5005]; int p[5005]; int sc[5005]; int leftpos[5005]; int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { for (int i = 0; i < N; i++) { in[i] = 1; } for (int i = 0; i < N-1; i++) K[i] = K[i] > R ? 1:0; fill(l,l+5000,-1); fill(r,r+5000,-1); fill(id,id+5000,-1); fill(p,p+5000,-1); iota(RR,RR+5000,0); for (int i = 0; i < C; i++){ int cur = 0; for (int j = 0; j < N; j++){ cur += in[j]; if (cur == S[i]+1 && l[i] == -1) l[i] = j; if (cur == E[i]+1 && r[i] == -1) r[i] = RR[j]; } for (int j = l[i]+1; j <= r[i]; j++){ in[j] = 0; if (id[j] == -1) id[j] = i; else if (p[id[j]] == -1){ p[id[j]] = i; } } RR[l[i]] = r[i]; if (id[l[i]] == -1) id[l[i]] = i; else if (p[id[l[i]]] == -1){ p[id[l[i]]] = i; } } for (int i = C-1; i >= 0; i--){ //printf("%d %d\n",l[i],r[i]); int mx = 0; int LEFT = -1; for (int j = l[i]; j < r[i]; j++){ mx |= K[j]; if (id[j] == i && LEFT == -1) LEFT = j; } if (id[r[i]] == i && LEFT == -1) LEFT = r[i]; if (mx){ sc[i] = 0; } else{ if (p[i] == -1) sc[i] = 1; else sc[i] = sc[p[i]] + 1; } leftpos[i] = LEFT; } int bestsc = 0; int ans = N-1; for (int i = 0; i < C; i++){ if (bestsc < sc[i]){ bestsc = sc[i]; ans = leftpos[i]; } else if (bestsc == sc[i]){ ans = min(ans,leftpos[i]); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...