답안 #349771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349771 2021-01-18T10:52:17 Z beksultan04 최후의 만찬 (IOI12_supper) C++14
0 / 100
121 ms 9912 KB
#include "advisor.h"
#include <bits/stdc++.h>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
int vis[100001],predok[100001],is[100001],pos[100001],ans[100001],INF = 1e9+7;
void ComputeAdvice(int *c, int N, int K, int M) {
    int i,j;
    set <pii> q;
    for (i=0;i<N;++i){
        vis[i] = INF;
    }
    for (i=N-1;i>=0;--i){
        predok[i] = vis[c[i]];
        vis[c[i]] = i;
    }
    for (i=0;i<K;++i){
        q.insert({-vis[i],i});
        pos[i] = i;
        is[i]=1;
    }
    for (j=0;j<N;++j){
        if (is[c[j]]){
            int x = c[j];
            q.erase({-vis[c[i]],x});
            vis[c[j]] = predok[j];
            pos[c[j]]=j+K;
        }
        else {
            int x = q.begin()->sc;
            ans[pos[x]]=1;
            q.erase(q.begin());
            is[x] = 0;
            pos[c[j]] = j+K;
            is[c[j]]=1;
        }
        q.insert({-predok[j],c[j]});
    }
    for (i=0;i<N;++i)WriteAdvice(ans[i]);
}







#include "assistant.h"
#include <bits/stdc++.h>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
int q[100001],iss[100001];
void Assist(unsigned char *A, int N, int K, int R) {

    int i,j,ans;
    for (i=0;i<K;++i)
        iss[i] = 1;
    int f=1;j=0;
    for (i=0;i<K;++i)q[i] = i;
    for (i=0;i<N;++i){
        int x = GetRequest();
        q[i] = x;
        if (iss[x] == 1)continue;
        else {
            while (A[j] == 0){
                j++;
            }
            if (j >= K && f){
                f=0;
                j -= K;
            }
            PutBack(q[j]);
            iss[q[j]]=0;
            j++;
        }
        iss[x] = 1;

    }

}











Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:31:13: warning: unused variable 'ans' [-Wunused-variable]
   31 |     int i,j,ans;
      |             ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 952 KB Output is correct
2 Incorrect 1 ms 868 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1704 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 88 ms 7896 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1316 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 107 ms 8968 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 104 ms 9224 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 117 ms 9300 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 108 ms 9232 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 109 ms 9736 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 113 ms 9224 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 107 ms 9340 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 121 ms 9912 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 110 ms 9096 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 88 ms 8444 KB Error - Putting back a color that is not on the scaffold