Submission #1018113

# Submission time Handle Problem Language Result Execution time Memory
1018113 2024-07-09T14:35:05 Z NintsiChkhaidze Last supper (IOI12_supper) C++17
100 / 100
90 ms 61280 KB
#include <bits/stdc++.h>
#include "advisor.h"
#define pb push_back
using namespace std;

const int MM = 2e6 + 5;

vector <int> st[MM];
bool onn[MM],val[MM],valk[MM];
bool fix[MM];

void ComputeAdvice(int *C, int N, int K, int M) {
	int n=N,k=K;
	for (int i=N-1;i>=0;i--){
		st[C[i]].pb(i);
	}
	
	set <pair<int,int> > stt;
	for (int i=0;i<K;i++){
		onn[i] = 1;
		int val = 0;
		if (!st[i].size()) val=1e9;
		else val=st[i].back();
		stt.insert({val,i});
	}
	
	int i;
	vector <int> vec;
	for (i = 0; i < N; i++) {
    	int req = C[i];
    	if (onn[req]) {
    		vec.pb(-1);
    		int val = 0;
			if (!st[req].size()) val=1e9;
			else val=st[req].back();
			stt.erase(stt.find({val,req}));
			
			while (st[req].size() && st[req].back() <= i){
    			st[req].pop_back();
			}
			val = 0;
			if (!st[req].size()) val=1e9;
			else val=st[req].back();
			stt.insert({val,req});
			continue;
		}
    	
		int idx=(--stt.end())->second; stt.erase(--stt.end());
		vec.pb(idx);
		onn[idx] = 0;
		onn[req] = 1;
		
		while (st[req].size() && st[req].back() <= i){
    		st[req].pop_back();
		}
		
		int val = 0;
		if (!st[req].size()) val=1e9;
		else val=st[req].back();
		stt.insert({val,req});
  	}
  	
	for (int i = n - 1; i >= 0; i--){
		val[i] = (!fix[C[i]]);
		fix[C[i]] = 1;
		fix[vec[i]] = 0;
	}
	
	for (int i=k-1;i>=0;i--){
		if (!fix[i]) valk[i] = 1;
	}
	
	for (int i=0;i<k;i++)
		WriteAdvice(valk[i]);
	for (int i=0;i<n;i++)
		WriteAdvice(val[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"
#define pb push_back
using namespace std;

int CC[2000005];
bool on[2000005];
int vall[2000005],vallk[2000005];

void Assist(unsigned char *A, int N, int K, int R) {
	int n=N;
	int k=K;
	
	for (int i = 0; i < k; i++)
		vallk[i] = A[i];
	for (int i=0;i<n;i++)
		vall[i] = A[i+k];
	
	vector <int> t2;
	for (int i=0;i<k;i++){
		if (!vallk[i]) on[i] = 1;
		else t2.pb(i);
	}
	
	int i;
	int l = 0;
	for (i = 0; i < N; i++) {
    	int req = GetRequest();
    	if (on[req]){
    		if (!vall[i]) continue;
    		on[req] = 0;
    		t2.pb(req);
    		continue;
		}
		
		PutBack(t2.back());
		t2.pop_back();
		
		if (!vall[i]){
			on[req] = 1;
		}else{
			t2.pb(req);
		}
  	}
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:26:6: warning: unused variable 'l' [-Wunused-variable]
   26 |  int l = 0;
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 10 ms 53292 KB Output is correct
2 Correct 11 ms 53300 KB Output is correct
3 Correct 13 ms 53572 KB Output is correct
4 Correct 16 ms 51524 KB Output is correct
5 Correct 13 ms 51688 KB Output is correct
6 Correct 13 ms 53584 KB Output is correct
7 Correct 12 ms 53592 KB Output is correct
8 Correct 13 ms 53832 KB Output is correct
9 Correct 15 ms 53760 KB Output is correct
10 Correct 13 ms 53728 KB Output is correct
11 Correct 13 ms 53796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 53888 KB Output is correct
2 Correct 41 ms 55820 KB Output is correct
3 Correct 71 ms 61192 KB Output is correct
4 Correct 53 ms 58296 KB Output is correct
5 Correct 53 ms 58304 KB Output is correct
6 Correct 63 ms 58840 KB Output is correct
7 Correct 75 ms 59576 KB Output is correct
8 Correct 60 ms 60084 KB Output is correct
9 Correct 48 ms 55232 KB Output is correct
10 Correct 90 ms 60412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 58768 KB Output is correct
2 Correct 83 ms 60088 KB Output is correct
3 Correct 78 ms 60144 KB Output is correct
4 Correct 78 ms 59880 KB Output is correct
5 Correct 77 ms 58676 KB Output is correct
6 Correct 88 ms 60072 KB Output is correct
7 Correct 82 ms 59888 KB Output is correct
8 Correct 68 ms 61280 KB Output is correct
9 Correct 64 ms 58828 KB Output is correct
10 Correct 80 ms 60152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 53572 KB Output is correct
2 Correct 13 ms 53832 KB Output is correct
3 Correct 12 ms 53580 KB Output is correct
4 Correct 16 ms 53584 KB Output is correct
5 Correct 13 ms 53580 KB Output is correct
6 Correct 12 ms 53592 KB Output is correct
7 Correct 12 ms 53588 KB Output is correct
8 Correct 13 ms 53564 KB Output is correct
9 Correct 13 ms 53584 KB Output is correct
10 Correct 13 ms 53844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 59616 KB Output is correct - 120000 bits used
2 Correct 81 ms 59808 KB Output is correct - 122000 bits used
3 Correct 77 ms 60220 KB Output is correct - 125000 bits used
4 Correct 79 ms 60144 KB Output is correct - 125000 bits used
5 Correct 76 ms 60100 KB Output is correct - 125000 bits used
6 Correct 77 ms 60092 KB Output is correct - 125000 bits used
7 Correct 75 ms 60068 KB Output is correct - 124828 bits used
8 Correct 79 ms 60144 KB Output is correct - 124910 bits used
9 Correct 77 ms 60144 KB Output is correct - 125000 bits used
10 Correct 64 ms 61160 KB Output is correct - 125000 bits used