Submission #578696

# Submission time Handle Problem Language Result Execution time Memory
578696 2022-06-17T16:13:31 Z WongChun1234 Last supper (IOI12_supper) C++14
0 / 100
138 ms 74928 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
int c[100050],curr[100050],lpos[100050],opt[200050];
deque<int> ap[100050];
priority_queue<pair<int,int>> pq;
void ComputeAdvice(int *C, int n, int k, int m) {
	for (int i=0;i<n;i++) c[i]=C[i];
	for (int i=0;i<n;i++) ap[c[i]].push_back(i);
	for (int i=0;i<n;i++) ap[i].push_back(2e9);
	for (int i=0;i<k;i++) curr[i]=lpos[i]=i,pq.push({ap[i][0],i});
	for (int i=k;i<n;i++) curr[i]=lpos[i]=-1;
	for (int i=0;i<n;i++){
		int choice;
		lpos[c[i]]=k+i;
		if (curr[c[i]]!=-1){
			choice=32767;
		}else{
			choice=curr[c[i]]=curr[pq.top().second];
			opt[lpos[pq.top().second]]=1;
			curr[pq.top().second]=-1;
			pq.pop();
		}
		while (ap[c[i]].front()<=i) ap[c[i]].pop_front();
		pq.push({ap[c[i]].front(),c[i]});
	}
	for (int i=0;i<n+k;i++) WriteAdvice(opt[i]);
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
int pos[100050];
priority_queue<int> dump;
void Assist(unsigned char *A, int n, int k, int R) {
	for (int i=0;i<k;i++) pos[i]=i;
	for (int i=k;i<n;i++) pos[i]=-1;
	for (int i=0;i<k;i++) if (A[i]) dump.push(i);
	for (int i=0;i<n;i++){
		int nxt=GetRequest();
		int choice=0;
		if (pos[nxt]!=-1){
		}else{
			PutBack(dump.top());
			pos[dump.top()]=-1;
			dump.pop();
			pos[choice]=nxt;
			if (A[i+k]) dump.push(nxt);
		}
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:15:7: warning: variable 'choice' set but not used [-Wunused-but-set-variable]
   15 |   int choice;
      |       ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 43 ms 67948 KB Output is correct
2 Incorrect 42 ms 67964 KB Error - Putting back a color when it is already on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 68484 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 118 ms 73352 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 68256 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 74652 KB Error - Putting back a color when it is already on the scaffold
2 Incorrect 130 ms 74764 KB Error - Putting back a color when it is already on the scaffold
3 Incorrect 130 ms 74928 KB Error - Putting back a color when it is already on the scaffold
4 Incorrect 129 ms 74760 KB Error - Putting back a color when it is already on the scaffold
5 Incorrect 127 ms 74732 KB Error - Putting back a color when it is already on the scaffold
6 Incorrect 132 ms 74740 KB Error - Putting back a color when it is already on the scaffold
7 Incorrect 128 ms 74720 KB Error - Putting back a color when it is already on the scaffold
8 Incorrect 131 ms 74800 KB Error - Putting back a color when it is already on the scaffold
9 Incorrect 138 ms 74752 KB Error - Putting back a color when it is already on the scaffold
10 Incorrect 135 ms 74420 KB Error - Putting back a color that is not on the scaffold