Submission #514841

# Submission time Handle Problem Language Result Execution time Memory
514841 2022-01-18T14:44:33 Z andrei_boaca Last supper (IOI12_supper) C++14
61 / 100
247 ms 142316 KB
#include <bits/stdc++.h>
#include "assistant.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();
            if(s.find(p)!=s.end())
                s.erase(s.find(p));
        }
        else
        {
            auto it=prev(s.end());
            s.erase(it);
            int p=(*it);
            p-=K;
            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"
#include "advisor.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])
        {
            if(buffer.find({there[nr],nr})!=buffer.end())
            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 86 ms 135108 KB Output is correct
2 Correct 79 ms 135048 KB Output is correct
3 Correct 78 ms 135352 KB Output is correct
4 Correct 77 ms 135548 KB Output is correct
5 Correct 88 ms 135508 KB Output is correct
6 Correct 82 ms 135752 KB Output is correct
7 Correct 80 ms 135424 KB Output is correct
8 Correct 84 ms 135356 KB Output is correct
9 Correct 82 ms 135796 KB Output is correct
10 Correct 91 ms 135508 KB Output is correct
11 Correct 85 ms 135380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 136044 KB Output is correct
2 Correct 138 ms 137452 KB Output is correct
3 Correct 217 ms 142316 KB Output is correct
4 Correct 154 ms 138672 KB Output is correct
5 Correct 192 ms 138788 KB Output is correct
6 Correct 181 ms 139312 KB Output is correct
7 Correct 207 ms 140736 KB Output is correct
8 Correct 203 ms 140528 KB Output is correct
9 Correct 136 ms 138596 KB Output is correct
10 Correct 247 ms 141816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 185 ms 140016 KB Output is correct
2 Correct 228 ms 141352 KB Output is correct
3 Correct 211 ms 141224 KB Output is correct
4 Correct 240 ms 141264 KB Output is correct
5 Correct 219 ms 140692 KB Output is correct
6 Correct 216 ms 141132 KB Output is correct
7 Correct 217 ms 141084 KB Output is correct
8 Correct 207 ms 141152 KB Output is correct
9 Correct 212 ms 141128 KB Output is correct
10 Correct 222 ms 141224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 135376 KB Output is correct
2 Correct 81 ms 135452 KB Output is correct
3 Correct 84 ms 135764 KB Output is correct
4 Correct 92 ms 135528 KB Output is correct
5 Correct 98 ms 135376 KB Output is correct
6 Correct 84 ms 135440 KB Output is correct
7 Correct 82 ms 135352 KB Output is correct
8 Correct 83 ms 135744 KB Output is correct
9 Correct 81 ms 135432 KB Output is correct
10 Correct 85 ms 136020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 208 ms 140728 KB Output is correct - 120000 bits used
2 Correct 212 ms 140868 KB Output is correct - 122000 bits used
3 Correct 215 ms 141316 KB Output is correct - 125000 bits used
4 Correct 222 ms 141144 KB Output is correct - 125000 bits used
5 Correct 214 ms 141128 KB Output is correct - 125000 bits used
6 Correct 223 ms 141140 KB Output is correct - 125000 bits used
7 Correct 238 ms 141132 KB Output is correct - 124828 bits used
8 Correct 231 ms 141348 KB Output is correct - 124910 bits used
9 Correct 214 ms 141148 KB Output is correct - 125000 bits used
10 Correct 186 ms 141300 KB Output is correct - 125000 bits used