답안 #1011318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011318 2024-06-30T10:23:21 Z amirhoseinfar1385 최후의 만찬 (IOI12_supper) C++17
0 / 100
217 ms 14384 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
set<pair<int,int>>st;
set<int>wtf;
int n,k,m,lgk;
int allk[maxn],nxt[maxn],last[maxn];

void wri(int x){
  for(int i=0;i<=lgk;i++){
    WriteAdvice((x>>i)&1);
  }
}
void ComputeAdvice(int *C, int N, int K, int M) {
  for(int i=0;;i++){
    if((1<<i)>=K){
      lgk=i;
      break;
    }
  }
  n=N;
  k=K;
  m=M;
  for(int i=0;i<maxn;i++){
    last[i]=n+1;
  }
  for(int i=n-1;i>=0;i--){
    nxt[i]=last[C[i]];
    last[C[i]]=i;
  }
  for(int i=0;i<k;i++){
    allk[i]=i;
    wtf.insert(i);
    st.insert(make_pair(last[allk[i]],i));
  }
  for(int i=0;i<N;i++){
    if(wtf.count(C[i])==1){
      continue;
    }
    int z=(*st.rbegin()).second;
    wri(z);
    st.erase((*st.rbegin()));
    wtf.erase(allk[z]);
    allk[z]=C[i];
    wtf.insert(C[i]);
    st.insert(make_pair(nxt[i],z));
  }
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int all[maxn],lgk2,n2,k2,r2;
set<int>st2;

void Assist(unsigned char *A, int N, int K, int R) {
   for(int i=0;;i++){
    if((1<<i)>=K){
      lgk2=i;
      break;
    }
  }
  n2=N;
  k2=K;
  r2=R;
  for(int i=0;i<k2;i++){
    all[i]=i;
    st2.insert(i);
  }
//  cout<<" wtf: "<<R<<endl;
  //for(int i=0;i<R;i++){
//    cout<<(int)A[i];
  //}
  //cout<<endl;
  int unnow=0;
  for(int i=0;i<n2;i++){
    int req=GetRequest();
    if(st2.count(req)==1){
      continue;
    }
    int x=0;
    for(int i=0;i<=lgk2;i++){
      if(A[unnow]==1){
        x+=(1<<i);
      }
      unnow++;
    }
 //   cout<<i<<" "<<x<<" "<<all[x]<<endl;
   PutBack(all[x]);
   st2.erase(all[x]);
   all[x]=req;
   st2.insert(req); 
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1048 KB Output is correct
2 Incorrect 1 ms 1044 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 2288 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 150 ms 10548 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1304 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 184 ms 12900 KB Output isn't correct - not an optimal way
2 Incorrect 176 ms 12984 KB Output isn't correct - not an optimal way
3 Incorrect 178 ms 12792 KB Output isn't correct - not an optimal way
4 Incorrect 217 ms 12656 KB Output isn't correct - not an optimal way
5 Incorrect 186 ms 12716 KB Output isn't correct - not an optimal way
6 Incorrect 180 ms 12660 KB Output isn't correct - not an optimal way
7 Incorrect 178 ms 12652 KB Output isn't correct - not an optimal way
8 Incorrect 189 ms 12672 KB Output isn't correct - not an optimal way
9 Incorrect 175 ms 12944 KB Output isn't correct - not an optimal way
10 Correct 179 ms 14384 KB Output is partially correct - 1192128 bits used