Submission #848078

# Submission time Handle Problem Language Result Execution time Memory
848078 2023-09-11T09:48:31 Z urd05 Last supper (IOI12_supper) C++17
0 / 100
72 ms 7044 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

int n,k,m;
bool chk[100000];
int nt[100000];
int pr[100000];

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;
    for(int i=0;i<n;i++) {
        if (pr[C[i]]!=-1) {
            nt[pr[C[i]]]=i;
        }
        pr[C[i]]=i;
        if (!chk[C[i]]) {
            chk[C[i]]=true;
            cnt++;
        }
        if (cnt==k) {
            ind=i;
            break;
        }
    }
    for(int i=0;i<k;i++) {
        if (chk[i]) {
            WriteAdvice(1);
        }
        else {
            WriteAdvice(0);
        }
    }
    for(int i=0;i<n;i++) {
        if (nt[i]>ind) {
            chk[C[i]]=false;
            ind++;
            cnt--;
            while (ind<n) {
                if (!chk[C[ind]]) {
                    cnt++;
                }
                if (cnt==k) {
                    break;
                }
                ind++;
            }
        }
        if (chk[C[i]]) {
            WriteAdvice(1);
        }
        else {
            WriteAdvice(0);
        }
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

bool save[100000];
bool isin[100000];
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);
    }
  }

}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1552 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2192 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 5772 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1612 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 6720 KB Output isn't correct - not an optimal way
2 Incorrect 64 ms 6720 KB Output isn't correct - not an optimal way
3 Incorrect 65 ms 6976 KB Output isn't correct - not an optimal way
4 Incorrect 67 ms 6984 KB Output isn't correct - not an optimal way
5 Incorrect 66 ms 6972 KB Output isn't correct - not an optimal way
6 Incorrect 68 ms 6988 KB Output isn't correct - not an optimal way
7 Incorrect 72 ms 6980 KB Output isn't correct - not an optimal way
8 Incorrect 64 ms 6936 KB Output isn't correct - not an optimal way
9 Incorrect 68 ms 6972 KB Output isn't correct - not an optimal way
10 Incorrect 61 ms 7044 KB Output isn't correct - not an optimal way