답안 #520198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
520198 2022-01-28T19:24:48 Z andrei_boaca 최후의 만찬 (IOI12_supper) C++17
100 / 100
277 ms 143404 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});
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 135172 KB Output is correct
2 Correct 80 ms 135208 KB Output is correct
3 Correct 79 ms 135260 KB Output is correct
4 Correct 80 ms 135356 KB Output is correct
5 Correct 89 ms 135448 KB Output is correct
6 Correct 81 ms 135500 KB Output is correct
7 Correct 84 ms 135520 KB Output is correct
8 Correct 81 ms 135460 KB Output is correct
9 Correct 84 ms 135496 KB Output is correct
10 Correct 85 ms 135576 KB Output is correct
11 Correct 85 ms 135516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 135852 KB Output is correct
2 Correct 137 ms 137896 KB Output is correct
3 Correct 230 ms 143404 KB Output is correct
4 Correct 207 ms 139900 KB Output is correct
5 Correct 184 ms 139820 KB Output is correct
6 Correct 246 ms 140492 KB Output is correct
7 Correct 217 ms 141892 KB Output is correct
8 Correct 202 ms 141732 KB Output is correct
9 Correct 155 ms 139896 KB Output is correct
10 Correct 238 ms 142804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 140944 KB Output is correct
2 Correct 219 ms 142292 KB Output is correct
3 Correct 240 ms 142384 KB Output is correct
4 Correct 244 ms 142316 KB Output is correct
5 Correct 219 ms 141844 KB Output is correct
6 Correct 223 ms 142344 KB Output is correct
7 Correct 224 ms 142460 KB Output is correct
8 Correct 210 ms 142468 KB Output is correct
9 Correct 277 ms 142424 KB Output is correct
10 Correct 253 ms 142444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 135372 KB Output is correct
2 Correct 85 ms 135788 KB Output is correct
3 Correct 88 ms 135444 KB Output is correct
4 Correct 93 ms 135336 KB Output is correct
5 Correct 87 ms 135644 KB Output is correct
6 Correct 83 ms 135360 KB Output is correct
7 Correct 87 ms 135380 KB Output is correct
8 Correct 108 ms 135432 KB Output is correct
9 Correct 88 ms 135508 KB Output is correct
10 Correct 106 ms 136084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 222 ms 141936 KB Output is correct - 120000 bits used
2 Correct 223 ms 142164 KB Output is correct - 122000 bits used
3 Correct 240 ms 142260 KB Output is correct - 125000 bits used
4 Correct 245 ms 142404 KB Output is correct - 125000 bits used
5 Correct 222 ms 142304 KB Output is correct - 125000 bits used
6 Correct 231 ms 142452 KB Output is correct - 125000 bits used
7 Correct 218 ms 142360 KB Output is correct - 124828 bits used
8 Correct 222 ms 142380 KB Output is correct - 124910 bits used
9 Correct 247 ms 142380 KB Output is correct - 125000 bits used
10 Correct 211 ms 142372 KB Output is correct - 125000 bits used