Submission #848110

# Submission time Handle Problem Language Result Execution time Memory
848110 2023-09-11T10:49:45 Z urd05 Last supper (IOI12_supper) C++17
0 / 100
77 ms 9432 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
 
int n,k,m;
bool chk[100000];
int nt[200000];
int pr[200000];
int type[200000];
typedef pair<int,int> P;
int arr[200000];
 
void ComputeAdvice(int *C, int N, int K, int M) {
    n=N;
    k=K;
    m=M;
    int cnt=0;
    memset(pr,-1,sizeof(pr));
    memset(nt,-1,sizeof(nt));
    int ind=n;
    set<P> s;
    for(int i=0;i<k;i++) {
        pr[i]=i;
        arr[i]=i;
    }
    for(int i=0;i<n;i++) {
        arr[i+k]=C[i];
        if (pr[C[i]]!=-1) {
            nt[pr[C[i]]]=i+k;
        }
        pr[C[i]]=i+k;
        if (!chk[C[i]]) {
            chk[C[i]]=true;
            cnt++;
        }
    }
    memset(pr,-1,sizeof(pr));
    memset(chk,0,sizeof(chk));
    for(int i=0;i<k;i++) {
        s.insert(P(nt[i],i));
        chk[i]=true;
    }
    cnt=k;
    for(int i=k;i<n+k;i++) {
        if (chk[arr[i]]) {
            pr[arr[i]]=i;
            continue;
        }
        if (cnt==k) {
            P now=*s.rbegin();
            type[now.second]=1;
            chk[arr[now.second]]=false;
            s.erase(now);
            chk[arr[i]]=true;
            s.insert(P(nt[i],i));
        }
        else {
            cnt++;
            chk[arr[i]]=true;
            s.insert(P(nt[i],i));
        }
        pr[arr[i]]=i;
    }
    for(int i=0;i<n+k;i++) {
        WriteAdvice(1-type[i]);
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

bool save[100000];
bool isin[100000];
typedef pair<int,int> P;
set<int> s;
int n,k,r;

void Assist(unsigned char *A, int N, int K, int R) {

  int i;
  n=N;
  k=K;
  r=R;
  for(int i=0;i<k;i++) {
    isin[i]=true;
    if (A[i]==1) {
        save[i]=true;
    }
    else {
        s.insert(i);
    }
  }
  for (i = 0; i < N; i++) {
    int req = GetRequest();
    if (!isin[req]) {
        int now=*s.begin();
        s.erase(now);
        PutBack(now);
        isin[now]=false;
        isin[req]=true;
    }
    save[req]=(A[i+k]==1);
    s.erase(req);
    if (!save[req]) {
        s.insert(req);
    }
  }

}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:20:9: warning: unused variable 'ind' [-Wunused-variable]
   20 |     int ind=n;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 3860 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4200 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 7948 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3892 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 8408 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 64 ms 8696 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 66 ms 8696 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 77 ms 8696 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 71 ms 8796 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 69 ms 8732 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 67 ms 8868 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 73 ms 8700 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 68 ms 8804 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 71 ms 9432 KB Error - Putting back a color that is not on the scaffold