답안 #393653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
393653 2021-04-24T07:52:38 Z Hazem 최후의 만찬 (IOI12_supper) C++14
0 / 100
549 ms 33520 KB
#include <bits/stdc++.h>
#include "advisor.h"
#define S second

using namespace std;

void appendint(int x,int len){
	
	//printf("%d\n",x);
	for(int i=0;i<=len;i++)
		WriteAdvice(char((1<<i)&x)>0);
}

const int N1 = 2e5+100;

int nxt[N1],last[N1];
vector<int>freq[N1];
map<int,int>pos;

void ComputeAdvice(int *C, int N, int K, int M) {

    int len = 0;
    for(int i=1;;i++){
		if((1<<i)>K)break;
		len = i;
	}
	
	int n = N;
	for(int i=0;i<n;i++)
		freq[C[i]].push_back(i);
	
	for(int i=0;i<n;i++)
		freq[i].push_back(n+100);
		
	set<pair<int,int>>st;
	set<int>st1;
	for(int i=0;i<K;i++)
		st.insert({freq[i][0],i}),st1.insert(i),pos[i] = i;
	
	for(int i=0;i<n;i++){
		
		if(st1.find(C[i])!=st1.end()){
			appendint(0,len);
      st.erase({i,C[i]});
      int nxt = upper_bound(freq[C[i]].begin(),freq[C[i]].end(),i)-freq[C[i]].begin();
			nxt = freq[C[i]][nxt];
      st.insert({nxt,C[i]});
    }
		
		else {
			
			auto it = st.rbegin();
			int val = (*it).S;
			
			st1.erase(val);
			st1.insert(C[i]);
			pos[C[i]] = pos[val];
			
			appendint(pos[val]+1,len);
			
			st.erase(*it);
			int nxt = upper_bound(freq[C[i]].begin(),freq[C[i]].end(),i)-freq[C[i]].begin();
			nxt = freq[C[i]][nxt];
			
			st.insert({nxt,C[i]});
		} 		
	}
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;

int a[2000000],vals[2000000];

int get(int idx,int len){
	
	int ret = 0;
	for(int i=idx;i<=idx+len;i++)
		ret += (1<<(i-idx))*a[i];
	
	return ret;
}

void Assist(unsigned char *A, int N, int K, int R) {
	
  // printf("%d\n",R);
	// for(int i=0;i<R;i++)
	// 	cout<<A[i];
		
	int len = 0;
	for(int i=0;;i++){
		if((1<<i)>K)break;
		len = i;
	}
	
	for(int i=0;i<K;i++)
		vals[i] = i;
		
	for(int i=0;i<R;i++)
		a[i] = A[i];
	
	int n = N;
	for(int i=0;i<n;i++){
		
		int val = GetRequest();
		int val1 = get(i*(len+1),len);
		
		if(!val1)continue;
		
		PutBack(vals[val1-1]);
		vals[val1-1] = val;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5236 KB Output is correct
2 Correct 4 ms 5296 KB Output is correct
3 Correct 8 ms 5644 KB Output is correct
4 Correct 9 ms 5684 KB Output is correct
5 Correct 9 ms 5784 KB Output is correct
6 Correct 21 ms 6080 KB Output is correct
7 Incorrect 17 ms 6136 KB Error - Not putting back color when it is not on the scaffold
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 7392 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 420 ms 26884 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5648 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 549 ms 31652 KB Error - Not putting back color when it is not on the scaffold
2 Incorrect 535 ms 31900 KB Error - Not putting back color when it is not on the scaffold
3 Incorrect 542 ms 32336 KB Error - Not putting back color when it is not on the scaffold
4 Incorrect 532 ms 32380 KB Error - Not putting back color when it is not on the scaffold
5 Incorrect 531 ms 32280 KB Error - Not putting back color when it is not on the scaffold
6 Incorrect 536 ms 32268 KB Error - Not putting back color when it is not on the scaffold
7 Incorrect 536 ms 32224 KB Error - Not putting back color when it is not on the scaffold
8 Incorrect 529 ms 32404 KB Error - Not putting back color when it is not on the scaffold
9 Incorrect 542 ms 32228 KB Error - Not putting back color when it is not on the scaffold
10 Incorrect 532 ms 33520 KB Error - Not putting back color when it is not on the scaffold