답안 #848098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
848098 2023-09-11T10:39:16 Z urd05 최후의 만찬 (IOI12_supper) C++17
0 / 100
77 ms 7172 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

int n,k,m;
bool chk[100000];
int nt[100000];
int pr[100000];
int type[100000];
typedef pair<int,int> P;

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);
        }
    }
    memset(pr,-1,sizeof(pr));
    memset(chk,0,sizeof(chk));
    cnt=0;
    set<P> s;
    for(int i=0;i<n;i++) {
        if (chk[C[i]]) {
            pr[C[i]]=i;
            continue;
        }
        if (cnt==k) {
            P now=*s.begin();
            type[now.second]=1;
            chk[C[now.second]]=false;
            s.erase(now);
            chk[C[i]]=true;
            s.insert(P(nt[i],i));
        }
        else {
            cnt++;
            chk[C[i]]=true;
            s.insert(P(nt[i],i));
        }
        pr[C[i]]=i;
    }
    for(int i=0;i<n;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:19:9: warning: variable 'ind' set but not used [-Wunused-but-set-variable]
   19 |     int ind=n;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1548 KB Output is correct
2 Incorrect 1 ms 1548 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2152 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 6176 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1840 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 6396 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 68 ms 6896 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 70 ms 6908 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 68 ms 6904 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 72 ms 6992 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 69 ms 7172 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 69 ms 6904 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 71 ms 6904 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 69 ms 7076 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 77 ms 7168 KB Output isn't correct - not an optimal way