Submission #514832

# Submission time Handle Problem Language Result Execution time Memory
514832 2022-01-18T14:35:14 Z andrei_boaca Last supper (IOI12_supper) C++14
0 / 100
216 ms 262144 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;
typedef pair<int,int> pii;
bool useful[200005];
int isthere[200005];
multiset<int> s;
deque<int> poz[200005];
int INF=1e9;
void ComputeAdvice(int *C, int N, int K, int M)
{
    for(int i=0;i<K;i++)
        poz[i].push_back(i);
    for(int j=0;j<N;j++)
        poz[C[j]].push_back(j+K);
    for(int i=0;i<=N+K;i++)
        useful[i]=0;
    for(int i=0;i<K;i++)
    {
        isthere[i]=i+1;
        poz[i].pop_front();
        if(poz[i].empty())
            s.insert(INF);
        else
            s.insert(poz[i].front());
    }
    for(int i=0;i<N;i++)
    {
        int nr=C[i];
        if(isthere[nr])
        {
            useful[isthere[nr]-1]=1;
            int p=poz[nr].front();
            s.erase(s.find(p));
        }
        else
        {
            auto it=prev(s.end());
            s.erase(it);
            int p=(*it);
            if(p<N&&p>0)
                isthere[C[p]]=0;
        }
        isthere[nr]=poz[nr].front()+1;
        poz[nr].pop_front();
        if(poz[nr].empty())
            s.insert(INF);
        else
            s.insert(poz[nr].front());
    }
    for(int i=0;i<N+K;i++)
        WriteAdvice(useful[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;
typedef pair<int,int> pii;


set<pii> buffer;
int there[200005];
void Assist(unsigned char *A, int N, int K, int R)
{
    for(int i=0;i<K;i++)
    {
        int x=A[i]-'0';
        if(x==0)
            x=-1;
        buffer.insert({x,i});
        there[i]=x;
    }
    for(int i=K;i<N+K;i++)
    {
        int nr=GetRequest();
        if(there[nr])
            buffer.erase({there[nr],nr});
        else
        {
            auto it=buffer.begin();
            int nr=(*it).second;
            buffer.erase(it);
            there[nr]=0;
            PutBack(nr);
        }
        int x=A[i]-'0';
        if(x==0)
            x=-1;
        there[nr]=x;
        buffer.insert({x,nr});
    }
}
# Verdict Execution time Memory Grader output
1 Correct 76 ms 135176 KB Output is correct
2 Correct 79 ms 135120 KB Output is correct
3 Correct 88 ms 135336 KB Output is correct
4 Runtime error 171 ms 262144 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 163 ms 262144 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 182 ms 140964 KB Output is correct
2 Correct 196 ms 142284 KB Output is correct
3 Correct 200 ms 142424 KB Output is correct
4 Correct 198 ms 142376 KB Output is correct
5 Runtime error 214 ms 262144 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 81 ms 135496 KB Output is correct
2 Runtime error 171 ms 262144 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 212 ms 262144 KB Execution killed with signal 6
2 Correct 201 ms 142116 KB Output is correct - 122000 bits used
3 Correct 196 ms 142464 KB Output is correct - 125000 bits used
4 Correct 196 ms 142528 KB Output is correct - 125000 bits used
5 Correct 199 ms 142520 KB Output is correct - 125000 bits used
6 Correct 203 ms 142368 KB Output is correct - 125000 bits used
7 Correct 216 ms 142248 KB Output is correct - 124828 bits used
8 Correct 206 ms 142532 KB Output is correct - 124910 bits used
9 Correct 201 ms 142276 KB Output is correct - 125000 bits used
10 Runtime error 207 ms 262144 KB Execution killed with signal 6