# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
363344 | 2021-02-05T15:37:56 Z | eric_xiao | Last supper (IOI12_supper) | C++14 | 279 ms | 24252 KB |
#include<bits/stdc++.h> #include "advisor.h" #define ll long long #define pii pair<int,int> #define F first #define S second using namespace std; int st[100009],th[100009],in[100009],last[100009]; set<int> occ[100009]; set<pii> nw; const int inf = 1000000; void ComputeAdvice(int *C, int N, int K, int M) { int i,j,k; for(i = 0;i < N;i++) { occ[C[i]].insert(i); last[i] = -1; } for(i = 0;i < N;i++) { occ[i].insert(inf); } for(i = 0;i < K;i++) { in[i] = 1; nw.insert({*occ[i].begin(),i}); } for(i = 0;i < N;i++) { /*cerr << "i = " << i << endl; for(j = 0;j < N;j++) { cerr << "j = " << j << ": \n"; for(auto x : occ[j]) { cerr << x << " "; } cerr << endl; } for(auto x : nw) { cerr << x.F << "_" << x.S << endl; }*/ last[C[i]] = i; if(in[C[i]] == 1) { auto p = nw.lower_bound({i,C[i]}); pii t = {*occ[C[i]].upper_bound(i),C[i]}; nw.erase(p); nw.insert(t); continue; } auto u = prev(nw.end()); in[u->S] = 0; in[C[i]] = 1; if(last[u->S] == -1) { st[u->S] = 1; } else { th[last[u->S]] = 1; } pii t = {*occ[C[i]].upper_bound(i),C[i]}; nw.erase(u); nw.insert(t); } for(auto x : nw) { if(last[x.S] == -1) { st[x.S] = 1; } else { th[last[x.S]] = 1; } } for(i = 0;i < N;i++) { if(st[i] == 0)WriteAdvice(0); else WriteAdvice(1); } for(i = 0;i < N;i++) { if(th[i] == 0)WriteAdvice(0); else WriteAdvice(1); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5348 KB | Output is correct |
2 | Correct | 4 ms | 5604 KB | Output is correct |
3 | Correct | 6 ms | 5836 KB | Output is correct |
4 | Correct | 8 ms | 6076 KB | Output is correct |
5 | Correct | 11 ms | 6260 KB | Output is correct |
6 | Correct | 11 ms | 6056 KB | Output is correct |
7 | Correct | 11 ms | 6420 KB | Output is correct |
8 | Correct | 13 ms | 6312 KB | Output is correct |
9 | Correct | 12 ms | 6440 KB | Output is correct |
10 | Correct | 13 ms | 6312 KB | Output is correct |
11 | Correct | 15 ms | 6528 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 7100 KB | Output is correct |
2 | Correct | 103 ms | 13740 KB | Output is correct |
3 | Correct | 237 ms | 24252 KB | Output is correct |
4 | Correct | 205 ms | 21008 KB | Output is correct |
5 | Correct | 189 ms | 20936 KB | Output is correct |
6 | Correct | 208 ms | 21396 KB | Output is correct |
7 | Correct | 242 ms | 23048 KB | Output is correct |
8 | Correct | 187 ms | 20960 KB | Output is correct |
9 | Correct | 166 ms | 20592 KB | Output is correct |
10 | Correct | 279 ms | 24132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 184 ms | 19136 KB | Output is correct |
2 | Correct | 251 ms | 23540 KB | Output is correct |
3 | Correct | 259 ms | 23572 KB | Output is correct |
4 | Correct | 253 ms | 23316 KB | Output is correct |
5 | Correct | 240 ms | 22980 KB | Output is correct |
6 | Correct | 248 ms | 23444 KB | Output is correct |
7 | Correct | 244 ms | 23636 KB | Output is correct |
8 | Correct | 225 ms | 23188 KB | Output is correct |
9 | Correct | 210 ms | 23156 KB | Output is correct |
10 | Correct | 248 ms | 24060 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 6416 KB | Output is correct |
2 | Correct | 12 ms | 6312 KB | Output is correct |
3 | Correct | 11 ms | 6056 KB | Output is correct |
4 | Correct | 11 ms | 6056 KB | Output is correct |
5 | Correct | 11 ms | 6208 KB | Output is correct |
6 | Correct | 11 ms | 6056 KB | Output is correct |
7 | Correct | 12 ms | 6312 KB | Output is correct |
8 | Correct | 14 ms | 6440 KB | Output is correct |
9 | Correct | 13 ms | 6312 KB | Output is correct |
10 | Correct | 13 ms | 6780 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 243 ms | 22056 KB | Output is correct - 200000 bits used |
2 | Correct | 245 ms | 22080 KB | Output is correct - 200000 bits used |
3 | Correct | 244 ms | 22376 KB | Output is correct - 200000 bits used |
4 | Correct | 261 ms | 22508 KB | Output is correct - 200000 bits used |
5 | Correct | 239 ms | 22376 KB | Output is correct - 200000 bits used |
6 | Correct | 262 ms | 22308 KB | Output is correct - 200000 bits used |
7 | Correct | 244 ms | 22100 KB | Output is correct - 199678 bits used |
8 | Correct | 243 ms | 22396 KB | Output is correct - 200000 bits used |
9 | Correct | 250 ms | 22228 KB | Output is correct - 200000 bits used |
10 | Correct | 229 ms | 22520 KB | Output is correct - 200000 bits used |