Submission #848090

# Submission time Handle Problem Language Result Execution time Memory
848090 2023-09-11T10:03:31 Z urd05 Last supper (IOI12_supper) C++17
0 / 100
73 ms 5912 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||nt[i]==-1) {
            chk[C[i]]=false;
            cnt--;
            if (ind!=n) {
                ind++;
                while (ind<n) {
                    if (!chk[C[ind]]) {
                        chk[C[ind]]=true;
                        cnt++;
                    }
                    if (cnt==k) {
                        break;
                    }
                    ind++;
                }
            }
        }
        //printf(".%d\n",chk[C[i]]);
        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 Correct 1 ms 1548 KB Output is correct
2 Incorrect 1 ms 1560 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2144 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 5152 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 1584 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 5680 KB Output isn't correct - not an optimal way
2 Incorrect 63 ms 5628 KB Output isn't correct - not an optimal way
3 Incorrect 73 ms 5840 KB Output isn't correct - not an optimal way
4 Incorrect 66 ms 5880 KB Output isn't correct - not an optimal way
5 Incorrect 65 ms 5892 KB Output isn't correct - not an optimal way
6 Incorrect 65 ms 5880 KB Output isn't correct - not an optimal way
7 Incorrect 71 ms 5780 KB Output isn't correct - not an optimal way
8 Incorrect 64 ms 5880 KB Output isn't correct - not an optimal way
9 Incorrect 65 ms 5912 KB Output isn't correct - not an optimal way
10 Incorrect 65 ms 5884 KB Output isn't correct - not an optimal way