Submission #888788

# Submission time Handle Problem Language Result Execution time Memory
888788 2023-12-18T07:50:03 Z abcvuitunggio Last supper (IOI12_supper) C++17
100 / 100
94 ms 13968 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> pos[100001];
int a[200001],b[100001],c[100001];
set <pair <int, int>> s;
void ComputeAdvice(int *C, int N, int K, int M){
    for (int i=0;i<N;i++)
        pos[i].push_back(1000000);
    for (int i=N-1;i>=0;i--)
        pos[C[i]].push_back(i+K);
    for (int i=0;i<K;i++){
        b[i]=i;
        c[i]=1;
        pos[i].push_back(i);
        pos[i].pop_back();
        s.insert({pos[i].back(),i});
    }
    for (int i=0;i<N;i++){
        if (c[C[i]]){
            a[b[C[i]]]=1;
            b[C[i]]=i+K;
            s.erase({pos[C[i]].back(),C[i]});
        }
        else{
            b[C[i]]=i+K;
            auto [x,y]=*--s.end();
            s.erase(--s.end());
            c[C[i]]=1;
            c[y]=0;
        }
        pos[C[i]].pop_back();
        s.insert({pos[C[i]].back(),C[i]});
    }
    for (int i=0;i<N+K;i++)
        WriteAdvice(a[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
int ch[100001];
void Assist(unsigned char *A, int N, int K, int R){
    vector <int> ve;
    for (int i=0;i<K;i++){
        if (!A[i])
            ve.push_back(i);
        ch[i]=1;
    }
    for (int i=0;i<N;i++){
        int c=GetRequest();
        if (!ch[c]){
            PutBack(ve.back());
            ch[ve.back()]=0;
            ch[c]=1;
            ve.pop_back();
        }
        if (!A[i+K])
            ve.push_back(c);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4624 KB Output is correct
2 Correct 1 ms 4624 KB Output is correct
3 Correct 3 ms 4624 KB Output is correct
4 Correct 3 ms 4644 KB Output is correct
5 Correct 4 ms 4672 KB Output is correct
6 Correct 4 ms 4660 KB Output is correct
7 Correct 5 ms 4912 KB Output is correct
8 Correct 4 ms 4916 KB Output is correct
9 Correct 4 ms 5168 KB Output is correct
10 Correct 5 ms 4928 KB Output is correct
11 Correct 4 ms 4924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 5224 KB Output is correct
2 Correct 39 ms 8344 KB Output is correct
3 Correct 84 ms 12936 KB Output is correct
4 Correct 70 ms 12236 KB Output is correct
5 Correct 56 ms 12048 KB Output is correct
6 Correct 61 ms 12320 KB Output is correct
7 Correct 81 ms 13412 KB Output is correct
8 Correct 70 ms 12416 KB Output is correct
9 Correct 52 ms 12792 KB Output is correct
10 Correct 82 ms 13968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 10900 KB Output is correct
2 Correct 94 ms 12540 KB Output is correct
3 Correct 77 ms 12604 KB Output is correct
4 Correct 79 ms 12516 KB Output is correct
5 Correct 76 ms 12536 KB Output is correct
6 Correct 87 ms 12628 KB Output is correct
7 Correct 77 ms 12492 KB Output is correct
8 Correct 66 ms 12280 KB Output is correct
9 Correct 68 ms 12900 KB Output is correct
10 Correct 83 ms 13000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4664 KB Output is correct
2 Correct 4 ms 4920 KB Output is correct
3 Correct 4 ms 4912 KB Output is correct
4 Correct 4 ms 4668 KB Output is correct
5 Correct 4 ms 4912 KB Output is correct
6 Correct 4 ms 4656 KB Output is correct
7 Correct 5 ms 4928 KB Output is correct
8 Correct 5 ms 4924 KB Output is correct
9 Correct 5 ms 4924 KB Output is correct
10 Correct 5 ms 4924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 12284 KB Output is correct - 120000 bits used
2 Correct 84 ms 12280 KB Output is correct - 122000 bits used
3 Correct 85 ms 12636 KB Output is correct - 125000 bits used
4 Correct 75 ms 12552 KB Output is correct - 125000 bits used
5 Correct 77 ms 12456 KB Output is correct - 125000 bits used
6 Correct 76 ms 12528 KB Output is correct - 125000 bits used
7 Correct 80 ms 12544 KB Output is correct - 124828 bits used
8 Correct 76 ms 12544 KB Output is correct - 124910 bits used
9 Correct 76 ms 12444 KB Output is correct - 125000 bits used
10 Correct 66 ms 12296 KB Output is correct - 125000 bits used