답안 #546935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546935 2022-04-09T03:08:20 Z Jesus 최후의 만찬 (IOI12_supper) C++17
0 / 100
392 ms 81400 KB
#include<bits/stdc++.h>
#include "advisor.h"

using namespace std;

//WriteAdvice(k);

int andamio[100000];
queue<int> rep[100000];

pair<int,int> st[400010];

void st_i(int j,int i=0,int pos=1){
    if(i==j){
        int aux=andamio[i];
        if(rep[aux].size()>0) aux=rep[aux].front();
        else aux=100000;
        st[pos]={aux,aux};
        return;
    }
    st_i((i+j)/2,i,pos*2);
    st_i(j,(i+j)/2+1,pos*2+1);
    st[pos].first=max(st[pos*2].first,st[pos*2+1].second);
    st[pos].second=min(st[pos*2].second,st[pos*2+1].second);
}

void st_ap(int j,int act,int i=0,int pos=1){
    if(i==j){
        int aux=andamio[i];
        if(rep[aux].size()>0) aux=rep[aux].front();
        else aux=100000;
        st[pos]={aux,aux};
        return;
    }
    if(st[pos*2].second==act) st_ap((i+j)/2,act,i,pos*2);
    else st_ap(j,act,(i+j)/2+1,pos*2+1);
    st[pos].first=max(st[pos*2].first,st[pos*2+1].second);
    st[pos].second=min(st[pos*2].second,st[pos*2+1].second);
}

void st_ag(int j,int act,int i=0,int pos=1){
    if(i==j){
        int aux=andamio[i];
        if(rep[aux].size()>0) aux=rep[aux].front();
        else aux=100000;
        st[pos]={aux,aux};
        return;
    }
    if(st[pos*2].first==act) st_ag((i+j)/2,act,i,pos*2);
    else st_ag(j,act,(i+j)/2+1,pos*2+1);
    st[pos].first=max(st[pos*2].first,st[pos*2+1].second);
    st[pos].second=min(st[pos*2].second,st[pos*2+1].second);
}

int return_min(int j,int i=0,int pos=1){
    if(i==j) return i;
    else if(st[pos].second==st[pos*2].second) return return_min((i+j)/2,i,pos*2);
    else return return_min(j,(i+j)/2+1,pos*2+1);
}

int return_max(int j,int i=0,int pos=1){
    if(i==j) return i;
    else if(st[pos].first==st[pos*2].first) return return_min((i+j)/2,i,pos*2);
    else return return_min(j,(i+j)/2+1,pos*2+1);
}

void ComputeAdvice(int *C, int N, int K, int M) {
    int lim=log2(K-1);
    int expo[lim+2];
    expo[0]=1;
    for(int i=1;i<=lim;i++){
        expo[i]=expo[i-1]*2;
    }
    if(expo[lim]<K-1) {
            lim++;
            expo[lim]=expo[lim-1]*2;
    }

    for(int i=0;i<N;i++){
        if(i<K) andamio[i]=i;
        rep[C[i]].push(i);
    }
    st_i(K-1);

    for(int i=0;i<N;i++){
        //cout<<st[1].first<<' '<<st[1].second<<' ';
        if(st[1].second==i){
            //WriteAdvice(0);
            //cout<<0;
            rep[return_min(K-1)].pop();
            st_ap(K-1,i);
        }
        else{
            int pos=return_max(K-1);
            int val=pos;
            //WriteAdvice(1);
            for(int j=lim;j>=0;j--){
                if(expo[j]<=val){
                    WriteAdvice(1);
                    //cout<<1;
                    val-=expo[j];
                }
                else WriteAdvice(0); //cout<<0;
            }
            rep[C[i]].pop(),
            andamio[pos]=C[i];
            st_ag(K-1,st[i].first);

        }
        //cout<<endl;
    }

}
#include<bits/stdc++.h>
#include "assistant.h"

using namespace std;

bool cont[100000];
int an[100000];

void Assist(unsigned char *A, int N, int K, int R) {
    int lim=log2(K-1);
    int expo[lim+2];
    expo[0]=1;
    for(int i=1;i<=lim;i++){
        expo[i]=expo[i-1]*2;
    }
    if(expo[lim]<K-1) {
            lim++;
            expo[lim]=expo[lim-1]*2;
    }

    for(int i=0;i<K;i++){
        cont[i]=1;
        an[i]=1;
    }

    int pos=0;
    for(int i=0;i<N;i++){
        int req=GetRequest();
        if(cont[req]==false){
            int val=0;
            for(int j=lim;j>=0;j--){
                if(A[pos]==1) val+=expo[j];
                pos++;
            }
            PutBack(an[val]);
            an[val]=0;
            an[val]=req;
            cont[req]=true;


        }
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 67944 KB Output is correct
2 Incorrect 41 ms 68048 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 82 ms 68940 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 309 ms 78808 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 67868 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 372 ms 81320 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 379 ms 81296 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 392 ms 81196 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 364 ms 81400 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 385 ms 81180 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 388 ms 81360 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 378 ms 81280 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 385 ms 81260 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 355 ms 81376 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 350 ms 79176 KB Error - Putting back a color that is not on the scaffold