Submission #349915

# Submission time Handle Problem Language Result Execution time Memory
349915 2021-01-18T16:53:06 Z tengiz05 Last supper (IOI12_supper) C++17
100 / 100
139 ms 6920 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int NN = 2e5+5;
int n, ans[NN], used[NN], nx[NN], lst[NN];
void ComputeAdvice(int *C, int n, int k, int m) {
	priority_queue<pair<int,int>> q;
	for(int i=0;i<n;i++)lst[i] = n, used[i] = -1;
	for(int i=n-1;i>=0;i--){
		nx[i] = lst[C[i]];
		lst[C[i]] = i;
	}
	for(int i=0;i<k;i++){
		q.push({lst[i], i});
		used[i] = i;
	}
	for(int i=0;i<n;i++){
		if(used[C[i]] != -1)ans[used[C[i]]] = 1;
		else {
			int x = q.top().second;q.pop();
			used[x] = -1;
		}used[C[i]] = k+i;
		q.push({nx[i], C[i]});
	}
	for(int i=0;i<n+k;i++)WriteAdvice(ans[i]);
}

#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int n, int k, int r) {
	set<int> x, y;
	for(int i=0;i<k;i++){
		if(A[i] == 0)x.insert(i);
		else y.insert(i);
	}
	for(int i=k;i<n+k;i++){
		int c = GetRequest();
		if(y.find(c) != y.end()){
			y.erase(c);
		}else {
			PutBack(*x.begin());
			x.erase(x.begin());
		}if(A[i] == 0)x.insert(c);
		else y.insert(c);
	}
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 740 KB Output is correct
2 Correct 1 ms 868 KB Output is correct
3 Correct 2 ms 748 KB Output is correct
4 Correct 3 ms 1016 KB Output is correct
5 Correct 4 ms 1132 KB Output is correct
6 Correct 5 ms 1032 KB Output is correct
7 Correct 6 ms 1160 KB Output is correct
8 Correct 5 ms 1224 KB Output is correct
9 Correct 5 ms 904 KB Output is correct
10 Correct 6 ms 1164 KB Output is correct
11 Correct 7 ms 1032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1656 KB Output is correct
2 Correct 54 ms 3328 KB Output is correct
3 Correct 125 ms 6912 KB Output is correct
4 Correct 74 ms 5252 KB Output is correct
5 Correct 79 ms 5176 KB Output is correct
6 Correct 103 ms 5428 KB Output is correct
7 Correct 121 ms 6592 KB Output is correct
8 Correct 92 ms 5568 KB Output is correct
9 Correct 68 ms 4988 KB Output is correct
10 Correct 127 ms 6812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 5676 KB Output is correct
2 Correct 139 ms 6768 KB Output is correct
3 Correct 125 ms 6624 KB Output is correct
4 Correct 128 ms 6824 KB Output is correct
5 Correct 118 ms 6384 KB Output is correct
6 Correct 123 ms 6480 KB Output is correct
7 Correct 124 ms 6672 KB Output is correct
8 Correct 104 ms 6316 KB Output is correct
9 Correct 125 ms 6688 KB Output is correct
10 Correct 124 ms 6624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1156 KB Output is correct
2 Correct 5 ms 1072 KB Output is correct
3 Correct 4 ms 1032 KB Output is correct
4 Correct 5 ms 1104 KB Output is correct
5 Correct 5 ms 1032 KB Output is correct
6 Correct 5 ms 952 KB Output is correct
7 Correct 6 ms 1032 KB Output is correct
8 Correct 7 ms 1032 KB Output is correct
9 Correct 6 ms 1064 KB Output is correct
10 Correct 8 ms 1296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 6572 KB Output is correct - 120000 bits used
2 Correct 121 ms 6592 KB Output is correct - 122000 bits used
3 Correct 126 ms 6476 KB Output is correct - 125000 bits used
4 Correct 124 ms 6604 KB Output is correct - 125000 bits used
5 Correct 124 ms 6476 KB Output is correct - 125000 bits used
6 Correct 123 ms 6920 KB Output is correct - 125000 bits used
7 Correct 123 ms 6656 KB Output is correct - 124828 bits used
8 Correct 125 ms 6608 KB Output is correct - 124910 bits used
9 Correct 123 ms 6608 KB Output is correct - 125000 bits used
10 Correct 110 ms 6548 KB Output is correct - 125000 bits used