# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
829923 |
2023-08-18T15:53:53 Z |
MODDI |
Last supper (IOI12_supper) |
C++14 |
|
110 ms |
144108 KB |
#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
int n;
stack<int> G[100105];
set<pii> activasion;
set<int> in_pq;
vi advice, out;
void ComputeAdvice(int *C, int N, int K, int M) {
n = N;
for(int i = n-1; i >= 0; i--)
G[C[i]].push(i);
for(int i = 0; i < K; i++){
int when = n + 1;
if(!G[i].empty()) when = G[i].top();
activasion.insert(mp(when, i));
in_pq.insert(i);
}
for(int i = 0; i < n + K; i++) advice.pb(1);
for(int i = 0; i < K; i++) out.pb(i);
for(int i = 0; i < n; i++){
G[C[i]].pop();
out[C[i]] = K + i;
if(in_pq.find(C[i]) == in_pq.end()){
pii sega = *activasion.rbegin();
activasion.erase(*activasion.rbegin());
in_pq.erase(sega.second);
advice[out[sega.second]] = 0;
}
int when = 0;
in_pq.insert(C[i]);
if(G[C[i]].empty())when = 100100;
else when = G[C[i]].top();
activasion.insert(mp(when, C[i]));
}
for(int i = 0; i < n+K; i++)
WriteAdvice(advice[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
void Assist(unsigned char *A, int N, int K, int R) {
int n = N, k = K;
set<int> odma, in;
for(int i = 0; i < K; i++){
if(A[i] == 0) odma.insert(i);
in.insert(i);
}
for(int i = 0; i < n; i++){
int adv = GetRequest();
if(in.find(adv) == in.end()){
PutBack(*odma.begin());
in.erase(*odma.begin());
odma.erase(odma.begin());
}
in.insert(adv);
if(A[i+k] == 0) odma.insert(adv);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
68076 KB |
Output is correct |
2 |
Correct |
31 ms |
67916 KB |
Output is correct |
3 |
Correct |
34 ms |
68340 KB |
Output is correct |
4 |
Runtime error |
77 ms |
137052 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
79 ms |
137648 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
91 ms |
142516 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
83 ms |
137392 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
96 ms |
143008 KB |
Execution killed with signal 11 |
2 |
Runtime error |
99 ms |
143432 KB |
Execution killed with signal 11 |
3 |
Runtime error |
98 ms |
144044 KB |
Execution killed with signal 11 |
4 |
Runtime error |
110 ms |
144096 KB |
Execution killed with signal 11 |
5 |
Runtime error |
106 ms |
144108 KB |
Execution killed with signal 11 |
6 |
Runtime error |
99 ms |
144096 KB |
Execution killed with signal 11 |
7 |
Runtime error |
100 ms |
144044 KB |
Execution killed with signal 11 |
8 |
Runtime error |
101 ms |
144056 KB |
Execution killed with signal 11 |
9 |
Runtime error |
100 ms |
144004 KB |
Execution killed with signal 11 |
10 |
Runtime error |
103 ms |
144004 KB |
Execution killed with signal 11 |