Submission #1011327

# Submission time Handle Problem Language Result Execution time Memory
1011327 2024-06-30T10:43:45 Z amirhoseinfar1385 Last supper (IOI12_supper) C++17
41 / 100
222 ms 16356 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],go[maxn],wh[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);
    go[i]=last[allk[i]];
    wh[i]=i;
    st.insert(make_pair(last[allk[i]],i));
  }
  for(int i=0;i<N;i++){
    if(wtf.count(C[i])==1){
      st.erase(make_pair(go[wh[C[i]]],wh[C[i]]));
      go[wh[C[i]]]=nxt[i];
      st.insert(make_pair(nxt[i],wh[C[i]]));
      continue;
    }
    int z=(*st.rbegin()).second;
    wri(z);
    st.erase((*st.rbegin()));
    wtf.erase(allk[z]);
    wh[C[i]]=z;
    go[z]=nxt[i];
    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;
    if(unnow>=R){
      assert(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); 
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1044 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 1 ms 1416 KB Output is correct
4 Correct 4 ms 1352 KB Output is correct
5 Correct 3 ms 1360 KB Output is correct
6 Correct 7 ms 1576 KB Output is correct
7 Correct 3 ms 1352 KB Output is correct
8 Correct 8 ms 1696 KB Output is correct
9 Correct 8 ms 1696 KB Output is correct
10 Correct 6 ms 1656 KB Output is correct
11 Correct 7 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2156 KB Output is correct
2 Correct 69 ms 5288 KB Output is correct
3 Correct 203 ms 16356 KB Output is correct
4 Correct 116 ms 9016 KB Output is correct
5 Correct 158 ms 11044 KB Output is correct
6 Correct 178 ms 12048 KB Output is correct
7 Correct 188 ms 13260 KB Output is correct
8 Correct 168 ms 13856 KB Output is correct
9 Correct 89 ms 7888 KB Output is correct
10 Correct 182 ms 13776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 147 ms 11064 KB Output is correct
2 Correct 184 ms 13440 KB Output is correct
3 Correct 181 ms 13444 KB Output is correct
4 Correct 173 ms 12952 KB Output is correct
5 Correct 150 ms 11108 KB Output is correct
6 Correct 182 ms 13408 KB Output is correct
7 Correct 176 ms 13252 KB Output is correct
8 Correct 222 ms 15940 KB Output is correct
9 Correct 124 ms 11120 KB Output is correct
10 Correct 181 ms 13480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1320 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 183 ms 12980 KB Output is partially correct - 823856 bits used
2 Correct 190 ms 13200 KB Output is partially correct - 791568 bits used
3 Correct 206 ms 13360 KB Output is partially correct - 759968 bits used
4 Correct 182 ms 13284 KB Output is partially correct - 759472 bits used
5 Correct 174 ms 13516 KB Output is partially correct - 757984 bits used
6 Correct 168 ms 13360 KB Output is partially correct - 759632 bits used
7 Correct 178 ms 13728 KB Output is partially correct - 758496 bits used
8 Correct 190 ms 13472 KB Output is partially correct - 760896 bits used
9 Correct 191 ms 13532 KB Output is partially correct - 760352 bits used
10 Correct 208 ms 15768 KB Output is partially correct - 1192128 bits used