답안 #848099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
848099 2023-09-11T10:43:57 Z urd05 최후의 만찬 (IOI12_supper) C++17
0 / 100
77 ms 8380 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;
 
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;
    }
    for(int i=0;i<n;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));
    }
    cnt=0;
    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+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:19:9: warning: unused variable 'ind' [-Wunused-variable]
   19 |     int ind=n;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3088 KB Output is correct
2 Incorrect 1 ms 3100 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 3684 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 7252 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3124 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 7908 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 69 ms 7944 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 69 ms 8352 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 66 ms 8376 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 68 ms 8188 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 71 ms 8380 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 68 ms 8232 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 66 ms 8160 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 67 ms 8068 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 77 ms 7900 KB Error - Putting back a color that is not on the scaffold