답안 #698503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698503 2023-02-13T16:00:47 Z arneves 최후의 만찬 (IOI12_supper) C++17
0 / 100
362 ms 77020 KB
/*
	  ______  _____  _______ _     _ _______ __   _  _____  _  _  _
	 |_____/ |     | |       |____/  |______ | \  | |     | |  |  |
	 |    \_ |_____| |_____  |    \_ ______| |  \_| |_____| |__|__|
	
	
	       .      .           .      .           .      .    	
	       _\/  \/_           _\/  \/_           _\/  \/_    	
	        _\/\/_             _\/\/_             _\/\/_     	
	    _\_\_\/\/_/_/_     _\_\_\/\/_/_/_     _\_\_\/\/_/_/_ 	
	     / /_/\/\_\ \       / /_/\/\_\ \       / /_/\/\_\ \  	
	        _/\/\_             _/\/\_             _/\/\_     	
	        /\  /\             /\  /\             /\  /\     	
	       '      '           '      '           '      '    	
	
*/
 
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
 
 
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdint>
#include <cmath>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>

using namespace std;

#include "advisor.h"

void ComputeAdvice(int *C, int N, int K, int M) {
	
	vector<deque<int> > times(N, deque<int>());
	
	for(int i=0; i<N; i++){
		times[C[i]].push_back(i);
	}
	
	for(int i=0; i<N; i++){
		times[i].push_back(1e6);
	}
	
	priority_queue<pair<int,int> > q;
	set<int> d;
	
	for(int i=0; i<K; i++){
		d.insert(i);
		q.push({times[i].front(),i});
	}
	
	for(int i=0; i<N; i++){
		times[C[i]].pop_front();
		if(d.find(C[i])==d.end()){
			d.insert(C[i]);
			
			int y=q.top().second; q.pop();
			while(d.find(y)==d.end()){
				y=q.top().second; q.pop();
			}
			d.erase(y);
			
			for(int bit=0; bit<log2(N); bit++){
				if((1<<bit)&y) WriteAdvice(1);
				else WriteAdvice(0);
			}
		}
		
		d.insert(C[i]);
		q.push({times[C[i]].front(),C[i]});
	}
}
/*
	  ______  _____  _______ _     _ _______ __   _  _____  _  _  _
	 |_____/ |     | |       |____/  |______ | \  | |     | |  |  |
	 |    \_ |_____| |_____  |    \_ ______| |  \_| |_____| |__|__|
	
	
	       .      .           .      .           .      .    	
	       _\/  \/_           _\/  \/_           _\/  \/_    	
	        _\/\/_             _\/\/_             _\/\/_     	
	    _\_\_\/\/_/_/_     _\_\_\/\/_/_/_     _\_\_\/\/_/_/_ 	
	     / /_/\/\_\ \       / /_/\/\_\ \       / /_/\/\_\ \  	
	        _/\/\_             _/\/\_             _/\/\_     	
	        /\  /\             /\  /\             /\  /\     	
	       '      '           '      '           '      '    	
	
*/
 
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
 
 
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdint>
#include <cmath>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>

using namespace std;

#include "assistant.h"

void Assist(unsigned char *A, int N, int K, int R) {
	
	set<int> s;
	for(int i=0; i<K; i++){
		s.insert(i);
	}
	
	int c=0;
	
	for (int i = 0; i < N; i++) {
		int req = GetRequest();
		
		if(s.find(req)==s.end()){
			int y=0;
			
			for(int bit=0; bit<log2(N); bit++){
				if(A[bit+c]) y|=(1<<bit);
			}
			c+=log2(N);
			PutBack(y);
			s.erase(y);
		}
		s.insert(req);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 516 KB Output is correct
2 Incorrect 0 ms 632 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 8024 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 227 ms 60632 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3436 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 296 ms 75624 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 298 ms 75708 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 280 ms 75868 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 279 ms 75684 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 281 ms 75724 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 289 ms 75808 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 286 ms 75672 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 284 ms 75740 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 297 ms 75720 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 362 ms 77020 KB Error - Putting back a color that is not on the scaffold