Submission #118046

# Submission time Handle Problem Language Result Execution time Memory
118046 2019-06-17T20:44:28 Z baqargam Last supper (IOI12_supper) C++14
100 / 100
118 ms 11760 KB
#include<bits/stdc++.h>
#include "advisor.h"
//#include "grader.h"

using namespace std;

void ComputeAdvice(int *C, int n, int k, int m) {//cout<<345;
    int ls[125005],nx[125005];
    set<pair<int,int> >q;
    int ret[125005],sc[125005];
    for(int i=0;i<=125000;i++){
        ls[i]=100000000;
        nx[i]=0;
        sc[i]=ret[i]=0;
    }
    for(int i=n-1;i>=0;i--){
        nx[i]=ls[C[i]];
        ls[C[i]]=i;
     //   cout<<nx[i]<<" ";
    }
    //cout<<endl;
    for(int i=0;i<k;i++){
        q.insert({-ls[i],i});
        sc[i]=1;
    }
    for(int i=k;i<k+n;i++){//cout<<i<<" "<<i-k<<" "<<C[i-k]<<" "<<sc[C[i-k]]<<endl;
        if(sc[C[i-k]]==1)
            {
                //cout<<q.size()<<" "<<q.begin()->first<<" "<<q.begin()->second<<"  * "<<k<<" "<<i<<endl;
                q.erase(q.lower_bound({-(i-k),-1000000}));
                q.insert({-nx[i-k],i});
                continue;
            }
        int j=q.begin()->second;
        q.erase(q.begin());
        q.insert({-nx[i-k],i});//cout<<j<<" "<<i<<" "<<i-k<<" "<<C[i-k]<<" "<<sc[C[i-k]]<<endl;
        if(j<k) sc[j]=0; else sc[C[j-k]]=0;
        sc[C[i-k]]=1;
        ret[j]=1;

    }
    for(int i=0;i<k+n;i++){
        WriteAdvice(ret[i]);
    }
}
#include<bits/stdc++.h>
#include "assistant.h"
//#include "grader.h"

using namespace std;

void Assist(unsigned char *A, int n, int k, int r) {
    int sc[200005];
    queue<int>q;
    for(int i=0;i<n;i++){
        sc[i]=0;
    }
    for(int i=0;i<k;i++){
        if((int)A[i]==1) {q.push(i);}
        sc[i]=1;
    }
    for(int i=0;i<n;i++){
        int a=GetRequest();
        if(sc[a]==0)
        {
            if(q.size()==0)PutBack(0);
            else
            {
                PutBack(q.front());
                sc[q.front()]=0;
                q.pop();
                sc[a]=1;
            }
        }
        if((int)A[i+k]==1) {q.push(a);}
    }

}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4608 KB Output is correct
2 Correct 6 ms 4608 KB Output is correct
3 Correct 7 ms 4608 KB Output is correct
4 Correct 8 ms 4608 KB Output is correct
5 Correct 10 ms 4864 KB Output is correct
6 Correct 9 ms 4608 KB Output is correct
7 Correct 10 ms 4864 KB Output is correct
8 Correct 9 ms 4864 KB Output is correct
9 Correct 9 ms 4864 KB Output is correct
10 Correct 9 ms 4864 KB Output is correct
11 Correct 9 ms 4864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 5120 KB Output is correct
2 Correct 41 ms 6840 KB Output is correct
3 Correct 93 ms 11760 KB Output is correct
4 Correct 60 ms 8176 KB Output is correct
5 Correct 63 ms 8344 KB Output is correct
6 Correct 78 ms 8944 KB Output is correct
7 Correct 118 ms 10224 KB Output is correct
8 Correct 77 ms 10224 KB Output is correct
9 Correct 57 ms 8176 KB Output is correct
10 Correct 100 ms 11248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 8432 KB Output is correct
2 Correct 94 ms 9472 KB Output is correct
3 Correct 93 ms 9456 KB Output is correct
4 Correct 94 ms 9456 KB Output is correct
5 Correct 95 ms 9096 KB Output is correct
6 Correct 96 ms 10848 KB Output is correct
7 Correct 94 ms 11024 KB Output is correct
8 Correct 86 ms 10736 KB Output is correct
9 Correct 81 ms 10776 KB Output is correct
10 Correct 108 ms 11008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4864 KB Output is correct
2 Correct 9 ms 4608 KB Output is correct
3 Correct 9 ms 4608 KB Output is correct
4 Correct 8 ms 4608 KB Output is correct
5 Correct 9 ms 4608 KB Output is correct
6 Correct 8 ms 4864 KB Output is correct
7 Correct 9 ms 4864 KB Output is correct
8 Correct 9 ms 4864 KB Output is correct
9 Correct 9 ms 4864 KB Output is correct
10 Correct 10 ms 5120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 9184 KB Output is correct - 120000 bits used
2 Correct 94 ms 9456 KB Output is correct - 122000 bits used
3 Correct 93 ms 9712 KB Output is correct - 125000 bits used
4 Correct 91 ms 9456 KB Output is correct - 125000 bits used
5 Correct 95 ms 9712 KB Output is correct - 125000 bits used
6 Correct 95 ms 9456 KB Output is correct - 125000 bits used
7 Correct 94 ms 9536 KB Output is correct - 124828 bits used
8 Correct 96 ms 9704 KB Output is correct - 124910 bits used
9 Correct 93 ms 9584 KB Output is correct - 125000 bits used
10 Correct 90 ms 9640 KB Output is correct - 125000 bits used