Submission #764762

# Submission time Handle Problem Language Result Execution time Memory
764762 2023-06-24T03:33:54 Z boyliguanhan Last supper (IOI12_supper) C++17
100 / 100
81 ms 6784 KB
#include "advisor.h"
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define N 200100
int n, res[N], used[N], nxt[N], last[N];
void ComputeAdvice(int *C, int n, int k, int m) {
	priority_queue<pair<int,int>> q;
	for(int i = 0; i < n; i++)
        last[i] = n, used[i] = -1;
	for(int i = n; i--;)
		nxt[i] = last[C[i]], last[C[i]] = i;
	for(int i = 0; i < k; i++)
		q.push({last[i], used[i] = i});
	for(int i = 0; i < n; i++){
		if(used[C[i]]+1) {
            res[used[C[i]]] = 1;
		} else {
			used[q.top().second] = -1;
            q.pop();
		}
        used[C[i]] = k+i;
		q.push({nxt[i], C[i]});
	}
	for(int i = 0; i < n+k; i++)
        WriteAdvice(res[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
void Assist(unsigned char *A, int n, int k, int r) {
	set<int> y;
  priority_queue<int, vector<int>, greater<int>> q;
	for(int i=0;i<k;i++){
    if(A[i])
      y.insert(i);
    else
      q.push(i);
  }
	for(int i=k;i<n+k;i++){
		int c = GetRequest();
		if(y.find(c) != y.end()){
			y.erase(c);
		} else {
			PutBack(q.top());
			q.pop();
		}
    if(A[i])
      y.insert(c);
		else
      q.push(c);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 524 KB Output is correct
2 Correct 0 ms 516 KB Output is correct
3 Correct 2 ms 792 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 2 ms 676 KB Output is correct
6 Correct 3 ms 804 KB Output is correct
7 Correct 4 ms 936 KB Output is correct
8 Correct 3 ms 932 KB Output is correct
9 Correct 4 ms 932 KB Output is correct
10 Correct 4 ms 944 KB Output is correct
11 Correct 4 ms 936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1372 KB Output is correct
2 Correct 33 ms 3132 KB Output is correct
3 Correct 73 ms 6784 KB Output is correct
4 Correct 43 ms 4900 KB Output is correct
5 Correct 50 ms 5012 KB Output is correct
6 Correct 65 ms 5184 KB Output is correct
7 Correct 73 ms 6116 KB Output is correct
8 Correct 53 ms 5484 KB Output is correct
9 Correct 42 ms 4864 KB Output is correct
10 Correct 79 ms 6480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 5264 KB Output is correct
2 Correct 78 ms 6352 KB Output is correct
3 Correct 74 ms 6364 KB Output is correct
4 Correct 75 ms 6444 KB Output is correct
5 Correct 73 ms 6076 KB Output is correct
6 Correct 75 ms 6392 KB Output is correct
7 Correct 77 ms 6348 KB Output is correct
8 Correct 61 ms 6188 KB Output is correct
9 Correct 72 ms 6360 KB Output is correct
10 Correct 74 ms 6412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 936 KB Output is correct
2 Correct 4 ms 940 KB Output is correct
3 Correct 4 ms 804 KB Output is correct
4 Correct 3 ms 812 KB Output is correct
5 Correct 3 ms 812 KB Output is correct
6 Correct 4 ms 896 KB Output is correct
7 Correct 4 ms 932 KB Output is correct
8 Correct 4 ms 928 KB Output is correct
9 Correct 4 ms 928 KB Output is correct
10 Correct 4 ms 1196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 6232 KB Output is correct - 120000 bits used
2 Correct 73 ms 6312 KB Output is correct - 122000 bits used
3 Correct 81 ms 6404 KB Output is correct - 125000 bits used
4 Correct 75 ms 6396 KB Output is correct - 125000 bits used
5 Correct 75 ms 6376 KB Output is correct - 125000 bits used
6 Correct 74 ms 6304 KB Output is correct - 125000 bits used
7 Correct 74 ms 6456 KB Output is correct - 124828 bits used
8 Correct 74 ms 6380 KB Output is correct - 124910 bits used
9 Correct 77 ms 6396 KB Output is correct - 125000 bits used
10 Correct 66 ms 6104 KB Output is correct - 125000 bits used