Submission #87223

# Submission time Handle Problem Language Result Execution time Memory
87223 2018-11-30T03:08:33 Z shoemakerjo Last supper (IOI12_supper) C++14
100 / 100
68 ms 8408 KB
#include "advisor.h"
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair <int, int> pii;
 
static int P[151515], K[151515];
static priority_queue <pii> Q;
static bool chk[151515], ans[151515];
 
void ComputeAdvice(int *C, int n, int k, int m)
{
	int i, t, x;
	
	for(i=0; i<n; i++) P[i] = n + k + 1;
	
	for(i=n-1; i>=0; i--){
		K[k + i] = P[C[i]];
		P[C[i]] = k + i;
	}
	
	for(i=0; i<k; i++){
		K[i] = P[i];
		P[i] = i; chk[i] = 1;
		Q.push(pii(K[i], i));
	}
	
	for(i=0; i<n; i++){
		if(!chk[C[i]]){
			for(; ;){
				t = Q.top().second; Q.pop();
				x = t >= k? C[t - k] : t;
				if(chk[x]){
					chk[x] = 0; ans[t] = 1;
					break;
				}
			}
			chk[C[i]] = 1;
		}
		Q.push(pii(K[k + i], k + i));
	}
	
	for(i=0; i<n+k; i++){
		WriteAdvice(ans[i]);
	}
}
#include "assistant.h"
 
#include <bits/stdc++.h>
 
using namespace std;
 
static vector <int> V;
static bool chk[101010];
 
void Assist(unsigned char *A, int n, int k, int r)
{
	int i, c;
	
	for(i=0; i<k; i++){
		if(A[i]) V.push_back(i);
		chk[i] = 1;
	}
	
	for(i=0; i<n; i++){
		c = GetRequest();
		if(!chk[c]){
			chk[V.back()] = 0;
			PutBack(V.back());
			V.pop_back();
		}
		if(A[k + i]) V.push_back(c);
		chk[c] = 1;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 756 KB Output is correct
2 Correct 4 ms 760 KB Output is correct
3 Correct 4 ms 796 KB Output is correct
4 Correct 5 ms 928 KB Output is correct
5 Correct 6 ms 1088 KB Output is correct
6 Correct 5 ms 1088 KB Output is correct
7 Correct 5 ms 1264 KB Output is correct
8 Correct 7 ms 1016 KB Output is correct
9 Correct 5 ms 1080 KB Output is correct
10 Correct 7 ms 1264 KB Output is correct
11 Correct 7 ms 1336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1264 KB Output is correct
2 Correct 32 ms 4352 KB Output is correct
3 Correct 66 ms 8408 KB Output is correct
4 Correct 55 ms 6640 KB Output is correct
5 Correct 56 ms 6896 KB Output is correct
6 Correct 62 ms 7392 KB Output is correct
7 Correct 67 ms 7896 KB Output is correct
8 Correct 55 ms 6880 KB Output is correct
9 Correct 56 ms 6584 KB Output is correct
10 Correct 68 ms 8408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 5856 KB Output is correct
2 Correct 67 ms 8328 KB Output is correct
3 Correct 67 ms 8152 KB Output is correct
4 Correct 67 ms 8152 KB Output is correct
5 Correct 62 ms 8096 KB Output is correct
6 Correct 66 ms 8152 KB Output is correct
7 Correct 66 ms 8352 KB Output is correct
8 Correct 65 ms 7912 KB Output is correct
9 Correct 63 ms 8408 KB Output is correct
10 Correct 65 ms 8152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1008 KB Output is correct
2 Correct 7 ms 1092 KB Output is correct
3 Correct 5 ms 1080 KB Output is correct
4 Correct 5 ms 1088 KB Output is correct
5 Correct 5 ms 1080 KB Output is correct
6 Correct 6 ms 1080 KB Output is correct
7 Correct 7 ms 1080 KB Output is correct
8 Correct 7 ms 1008 KB Output is correct
9 Correct 7 ms 1080 KB Output is correct
10 Correct 7 ms 1264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 6872 KB Output is correct - 120000 bits used
2 Correct 67 ms 6872 KB Output is correct - 122000 bits used
3 Correct 67 ms 7128 KB Output is correct - 125000 bits used
4 Correct 67 ms 7008 KB Output is correct - 125000 bits used
5 Correct 67 ms 7128 KB Output is correct - 125000 bits used
6 Correct 67 ms 7128 KB Output is correct - 125000 bits used
7 Correct 67 ms 7136 KB Output is correct - 124828 bits used
8 Correct 66 ms 7072 KB Output is correct - 124910 bits used
9 Correct 66 ms 7128 KB Output is correct - 125000 bits used
10 Correct 66 ms 6632 KB Output is correct - 125000 bits used