답안 #848085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
848085 2023-09-11T09:54:36 Z urd05 최후의 만찬 (IOI12_supper) C++17
0 / 100
48 ms 6004 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]]) {
                    chk[C[ind]]=true;
                    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);
    }
  }

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1564 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1892 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 5056 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1592 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 5456 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 46 ms 5480 KB Output isn't correct - not an optimal way
3 Incorrect 48 ms 5932 KB Output isn't correct - not an optimal way
4 Incorrect 44 ms 5960 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 47 ms 5924 KB Output isn't correct - not an optimal way
6 Incorrect 44 ms 5924 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 47 ms 5992 KB Output isn't correct - not an optimal way
8 Incorrect 48 ms 5884 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 45 ms 5844 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 47 ms 6004 KB Output isn't correct - not an optimal way