Submission #1023048

# Submission time Handle Problem Language Result Execution time Memory
1023048 2024-07-14T09:00:23 Z boyliguanhan Last supper (IOI12_supper) C++17
100 / 100
129 ms 8856 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
bitset<500100>onf;
void ComputeAdvice(int *C, int N, int K, int M) {
    vector<int>nxt(N),lst(N,N),plat(K),dead(N+K,N-1);
    iota(plat.begin(),plat.end(),0);
    C[N]=N+5;
    for(int i=N;i--;)
        nxt[i]=lst[C[i]],
        lst[C[i]]=i;
    set<pair<int,int>> st;
    for(auto i:plat)onf[i]=1,
        st.insert({lst[i],i+N});
    int df=log2(2*K-1);
    for(int i=0;i<N;i++){
        if(onf[C[i]]){
            auto [x,y]=*st.lower_bound({i,0});
            st.erase({x,y});
            st.insert({nxt[i],i});
            continue;
        }
        onf[C[i]]=1;
        auto[x,y]=*--st.end();
        dead[y]=i;
        st.erase({x,y});
        st.insert({nxt[i],i});
        onf[C[x]]=0;
    }
    for(int i=0;i<K;i++)
        nxt.push_back(lst[i]);
    for(int i=0;i<N+K;i++)
        WriteAdvice(dead[i]<nxt[i]);
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
bitset<500100>on;
void Assist(unsigned char *A, int N, int K, int R) {
    set<int>passive;
    for(int i=0;i<K;on[i]=1,i++)
        if(A[N+i])
            passive.insert(i);
    for(int i=0;i<N;i++){
        int x=GetRequest();
        if(on[x]) { if(A[i])
                passive.insert(x);
            continue;
        }
        int die=*passive.begin();
        PutBack(die);
        on[die]=0;on[x]=1;
        passive.erase(die);
        if(A[i])passive.insert(x);
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:15:9: warning: unused variable 'df' [-Wunused-variable]
   15 |     int df=log2(2*K-1);
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 784 KB Output is correct
2 Correct 0 ms 784 KB Output is correct
3 Correct 1 ms 1056 KB Output is correct
4 Correct 2 ms 816 KB Output is correct
5 Correct 2 ms 1092 KB Output is correct
6 Correct 5 ms 1100 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 3 ms 1108 KB Output is correct
9 Correct 3 ms 1104 KB Output is correct
10 Correct 3 ms 1100 KB Output is correct
11 Correct 5 ms 1096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1432 KB Output is correct
2 Correct 28 ms 3368 KB Output is correct
3 Correct 87 ms 8856 KB Output is correct
4 Correct 38 ms 5140 KB Output is correct
5 Correct 49 ms 5428 KB Output is correct
6 Correct 55 ms 5700 KB Output is correct
7 Correct 65 ms 7220 KB Output is correct
8 Correct 71 ms 6992 KB Output is correct
9 Correct 54 ms 5120 KB Output is correct
10 Correct 101 ms 8364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 6172 KB Output is correct
2 Correct 93 ms 7664 KB Output is correct
3 Correct 71 ms 7728 KB Output is correct
4 Correct 76 ms 7736 KB Output is correct
5 Correct 88 ms 7196 KB Output is correct
6 Correct 69 ms 7780 KB Output is correct
7 Correct 104 ms 7732 KB Output is correct
8 Correct 97 ms 7784 KB Output is correct
9 Correct 60 ms 7736 KB Output is correct
10 Correct 129 ms 7892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1088 KB Output is correct
2 Correct 5 ms 1180 KB Output is correct
3 Correct 3 ms 1100 KB Output is correct
4 Correct 4 ms 972 KB Output is correct
5 Correct 5 ms 1096 KB Output is correct
6 Correct 4 ms 1104 KB Output is correct
7 Correct 4 ms 1096 KB Output is correct
8 Correct 4 ms 1096 KB Output is correct
9 Correct 3 ms 1096 KB Output is correct
10 Correct 7 ms 1360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 7388 KB Output is correct - 120000 bits used
2 Correct 79 ms 7440 KB Output is correct - 122000 bits used
3 Correct 81 ms 7740 KB Output is correct - 125000 bits used
4 Correct 77 ms 7744 KB Output is correct - 125000 bits used
5 Correct 74 ms 7796 KB Output is correct - 125000 bits used
6 Correct 81 ms 7696 KB Output is correct - 125000 bits used
7 Correct 72 ms 7736 KB Output is correct - 124828 bits used
8 Correct 75 ms 7612 KB Output is correct - 124910 bits used
9 Correct 73 ms 7876 KB Output is correct - 125000 bits used
10 Correct 68 ms 7760 KB Output is correct - 125000 bits used