Submission #829956

# Submission time Handle Problem Language Result Execution time Memory
829956 2023-08-18T16:16:56 Z MODDI Last supper (IOI12_supper) C++14
0 / 100
190 ms 143396 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<K;i++) out.pb(i);
	for(int i=0;i<n+K;i++) advice.pb(1);
	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.begin();
	      	activasion.erase(*activasion.begin());
	      	in_pq.erase(sega.second);
	      	advice[out[sega.second]]=0;
	    }
	    
	    int when = 0;
	    in_pq.insert(C[i]);
	    if(G[C[i]].empty()) when=n+1;
	    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;
 
void Assist(unsigned char *A, int N, int K, int R) {
	int n = N;
	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.emplace(adv);
	    if(A[i+K]==0) odma.emplace(adv);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 35 ms 67816 KB Output is correct
2 Correct 29 ms 68092 KB Output is correct
3 Correct 33 ms 68344 KB Output is correct
4 Runtime error 74 ms 137056 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 77 ms 137720 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 92 ms 142532 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 80 ms 137352 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 93 ms 142960 KB Execution killed with signal 11
2 Runtime error 95 ms 143396 KB Execution killed with signal 11
3 Correct 187 ms 77904 KB Output is correct - 125000 bits used
4 Correct 186 ms 77896 KB Output is correct - 125000 bits used
5 Correct 182 ms 77892 KB Output is correct - 125000 bits used
6 Correct 190 ms 77872 KB Output is correct - 125000 bits used
7 Correct 187 ms 77912 KB Output is correct - 124828 bits used
8 Correct 181 ms 77932 KB Output is correct - 124910 bits used
9 Correct 179 ms 77932 KB Output is correct - 125000 bits used
10 Correct 169 ms 76232 KB Output is correct - 125000 bits used