Submission #137454

# Submission time Handle Problem Language Result Execution time Memory
137454 2019-07-27T18:47:54 Z jangwonyoung Last supper (IOI12_supper) C++14
100 / 100
188 ms 13296 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int n,k;
int prv[200001];
int nxt[200001];
int c[200001];
int in[200001];
bool die[200001];
set<pair<int,int> >v;
void ComputeAdvice(int *C, int N, int K, int M) {
	n=N;k=K;
	for(int i=1; i<=n ;i++){
		c[k+i]=C[i-1]+1;
		prv[i]=n+k+1;
	}
	for(int i=1; i<=k ;i++) c[i]=i;
	for(int i=n+k; i>=1 ;i--){
		nxt[i]=prv[c[i]];
		if(i<=k) v.insert({nxt[i],i});
		prv[c[i]]=i;
		if(i<=k) in[i]=true;
	}
	for(int i=k+1; i<=n+k ;i++){
		if(!in[c[i]]){
			auto it=v.end();--it;
			die[it->se]=true;
			in[c[it->se]]=0;
			v.erase(it);
		}
		else{
			v.erase({i,in[c[i]]});
		}
		v.insert({nxt[i],i});
		in[c[i]]=i;
	}
	for(int i=1; i<=n+k ;i++){
		WriteAdvice(die[i]);
	}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int n,k;
bool s[200001];
set<pair<int,int> >bin[2];
void Assist(unsigned char *A, int N, int K, int R){
	n=N;k=K;
	for(int i=1; i<=n+k ;i++) s[i]=!A[i-1];
	for(int i=1; i<=k ;i++){
		bin[s[i]].insert({i,i});
	}
	for(int i=k+1; i<=n+k ;i++){
		int cur=GetRequest()+1;
		auto it=bin[1].lower_bound({cur,0});
		if(it==bin[1].end() || it->fi!=cur){
			it=bin[0].begin();
			PutBack(it->fi-1);
			int duh=it->se;
			bin[0].erase(it);
			bin[s[i]].insert({cur,duh});
		}
		else{
			auto tmp=*it;
			bin[1].erase(it);
			bin[s[i]].insert(tmp);
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 880 KB Output is correct
2 Correct 4 ms 752 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 6 ms 772 KB Output is correct
5 Correct 7 ms 1008 KB Output is correct
6 Correct 8 ms 1044 KB Output is correct
7 Correct 9 ms 1108 KB Output is correct
8 Correct 9 ms 1264 KB Output is correct
9 Correct 8 ms 1264 KB Output is correct
10 Correct 10 ms 1312 KB Output is correct
11 Correct 10 ms 1264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1776 KB Output is correct
2 Correct 75 ms 4320 KB Output is correct
3 Correct 161 ms 13296 KB Output is correct
4 Correct 79 ms 7832 KB Output is correct
5 Correct 88 ms 7664 KB Output is correct
6 Correct 113 ms 8688 KB Output is correct
7 Correct 149 ms 11240 KB Output is correct
8 Correct 121 ms 11536 KB Output is correct
9 Correct 76 ms 7688 KB Output is correct
10 Correct 163 ms 13040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 8688 KB Output is correct
2 Correct 188 ms 10864 KB Output is correct
3 Correct 161 ms 12216 KB Output is correct
4 Correct 159 ms 12016 KB Output is correct
5 Correct 163 ms 10944 KB Output is correct
6 Correct 157 ms 12376 KB Output is correct
7 Correct 170 ms 12504 KB Output is correct
8 Correct 138 ms 13040 KB Output is correct
9 Correct 148 ms 11256 KB Output is correct
10 Correct 157 ms 12016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1040 KB Output is correct
2 Correct 9 ms 1264 KB Output is correct
3 Correct 8 ms 1128 KB Output is correct
4 Correct 7 ms 1044 KB Output is correct
5 Correct 8 ms 1008 KB Output is correct
6 Correct 8 ms 1100 KB Output is correct
7 Correct 10 ms 1060 KB Output is correct
8 Correct 10 ms 1172 KB Output is correct
9 Correct 10 ms 1264 KB Output is correct
10 Correct 13 ms 1520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 10424 KB Output is correct - 120000 bits used
2 Correct 156 ms 10680 KB Output is correct - 122000 bits used
3 Correct 156 ms 10936 KB Output is correct - 125000 bits used
4 Correct 157 ms 11248 KB Output is correct - 125000 bits used
5 Correct 160 ms 10992 KB Output is correct - 125000 bits used
6 Correct 176 ms 10992 KB Output is correct - 125000 bits used
7 Correct 159 ms 10968 KB Output is correct - 124828 bits used
8 Correct 157 ms 11008 KB Output is correct - 124910 bits used
9 Correct 159 ms 10992 KB Output is correct - 125000 bits used
10 Correct 136 ms 12016 KB Output is correct - 125000 bits used