Submission #349793

# Submission time Handle Problem Language Result Execution time Memory
349793 2021-01-18T12:11:54 Z beksultan04 Last supper (IOI12_supper) C++14
100 / 100
131 ms 8904 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[200001],predok[200001],is[200001],pos[200001],ans[200001],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[j]],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+K;++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[200001],iss[200001];
void Assist(unsigned char *A, int N, int K, int R) {

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

    }

}











Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:36:9: warning: unused variable 'f' [-Wunused-variable]
   36 |     int f=1;j=0;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 740 KB Output is correct
2 Correct 1 ms 740 KB Output is correct
3 Correct 3 ms 876 KB Output is correct
4 Correct 3 ms 1016 KB Output is correct
5 Correct 5 ms 1088 KB Output is correct
6 Correct 5 ms 904 KB Output is correct
7 Correct 7 ms 1032 KB Output is correct
8 Correct 5 ms 1044 KB Output is correct
9 Correct 7 ms 1160 KB Output is correct
10 Correct 7 ms 1212 KB Output is correct
11 Correct 7 ms 1160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1580 KB Output is correct
2 Correct 49 ms 4400 KB Output is correct
3 Correct 113 ms 8692 KB Output is correct
4 Correct 67 ms 6280 KB Output is correct
5 Correct 73 ms 6924 KB Output is correct
6 Correct 89 ms 7316 KB Output is correct
7 Correct 112 ms 8360 KB Output is correct
8 Correct 81 ms 6848 KB Output is correct
9 Correct 68 ms 6308 KB Output is correct
10 Correct 124 ms 8904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 7092 KB Output is correct
2 Correct 118 ms 8528 KB Output is correct
3 Correct 131 ms 8704 KB Output is correct
4 Correct 119 ms 8784 KB Output is correct
5 Correct 125 ms 8368 KB Output is correct
6 Correct 121 ms 8636 KB Output is correct
7 Correct 119 ms 8676 KB Output is correct
8 Correct 94 ms 7612 KB Output is correct
9 Correct 95 ms 8272 KB Output is correct
10 Correct 117 ms 8636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1284 KB Output is correct
2 Correct 6 ms 1032 KB Output is correct
3 Correct 5 ms 904 KB Output is correct
4 Correct 5 ms 1032 KB Output is correct
5 Correct 5 ms 1064 KB Output is correct
6 Correct 5 ms 1032 KB Output is correct
7 Correct 6 ms 1160 KB Output is correct
8 Correct 6 ms 1288 KB Output is correct
9 Correct 6 ms 1160 KB Output is correct
10 Correct 7 ms 1424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 8464 KB Output is correct - 120000 bits used
2 Correct 117 ms 8376 KB Output is correct - 122000 bits used
3 Correct 113 ms 8636 KB Output is correct - 125000 bits used
4 Correct 130 ms 8776 KB Output is correct - 125000 bits used
5 Correct 120 ms 8704 KB Output is correct - 125000 bits used
6 Correct 123 ms 8724 KB Output is correct - 125000 bits used
7 Correct 122 ms 8584 KB Output is correct - 124828 bits used
8 Correct 119 ms 8636 KB Output is correct - 124910 bits used
9 Correct 117 ms 8636 KB Output is correct - 125000 bits used
10 Correct 112 ms 7800 KB Output is correct - 125000 bits used