답안 #70104

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70104 2018-08-22T11:07:41 Z Abelyan 최후의 만찬 (IOI12_supper) C++17
100 / 100
158 ms 31256 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

const int N=100006;
int a[N],han[N],mp[N],vr[N];
bool pas[N],sc[N];

void ComputeAdvice(int *c, int n, int k, int m) {
    for (int i=n-1;i>=0;i--){
        a[i]=mp[c[i]]-1;
        if (mp[c[i]]==0)a[i]=2*N;
        mp[c[i]]=i+1;
    }
    priority_queue<pair<pair<int,int>,int> > pq;
    for (int i=0;i<k;i++){
        if (mp[i]==0)mp[i]=2*N;
        pq.push({{mp[i]-1,-1},i});
        vr[i]=-1;
        sc[i]=true;
    }
    for (int i=0;i<n;i++){
        if (sc[c[i]]){
            pq.push({{a[i],i},c[i]});
            vr[c[i]]=i;
            han[i]=-1;
            continue;
        }
        sc[c[i]]=true;
        int k;
        do{
            han[i]=pq.top().second;
            k=pq.top().first.second;
            pq.pop();
        }while(vr[han[i]]!=k);
        //cout<<i<< " "<<han[i]<<endl;
        sc[han[i]]=false;
        pq.push({{a[i],i},c[i]});
        vr[c[i]]=i;
    }
    //cout<<endl;
    vector<int> v;
    for (int i=n-1;i>=0;i--){
        if (pas[c[i]])v.push_back(1);
        else v.push_back(0);
        if (han[i]!=-1)
        pas[han[i]]=false;
        pas[c[i]]=true;
    }
    for (int i=k-1;i>=0;i--){
        if (pas[i])v.push_back(1);
        else v.push_back(0);
    }
    reverse(v.begin(),v.end());
    for (int i=0;i<v.size();i++){
        //cout<<v[i]<<" ";
        WriteAdvice(v[i]);
    }
    //cout<<endl;
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

const int N=100006;
queue<int> s;
bool onsc[N];

void Assist(unsigned char *A, int n, int v, int R) {
    for (int i=0;i<v;i++){
        if (!A[i])s.push(i);
        onsc[i]=true;
    }
    for (int i=0;i<n;i++){
        int k=GetRequest();
        if (!A[i+v])s.push(k);
        if (onsc[k])continue;
        onsc[k]=true;
        PutBack(s.front());
        //cout<<s.front()<<endl;
        onsc[s.front()]=false;
        s.pop();

    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:55:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v.size();i++){
                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 752 KB Output is correct
2 Correct 5 ms 1008 KB Output is correct
3 Correct 5 ms 1080 KB Output is correct
4 Correct 10 ms 1600 KB Output is correct
5 Correct 11 ms 1664 KB Output is correct
6 Correct 10 ms 1952 KB Output is correct
7 Correct 8 ms 2152 KB Output is correct
8 Correct 9 ms 2232 KB Output is correct
9 Correct 14 ms 2280 KB Output is correct
10 Correct 9 ms 2392 KB Output is correct
11 Correct 10 ms 2440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2792 KB Output is correct
2 Correct 74 ms 6352 KB Output is correct
3 Correct 100 ms 13056 KB Output is correct
4 Correct 122 ms 13056 KB Output is correct
5 Correct 89 ms 13056 KB Output is correct
6 Correct 107 ms 14352 KB Output is correct
7 Correct 99 ms 16376 KB Output is correct
8 Correct 117 ms 16376 KB Output is correct
9 Correct 82 ms 16856 KB Output is correct
10 Correct 104 ms 20160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 20160 KB Output is correct
2 Correct 110 ms 21112 KB Output is correct
3 Correct 101 ms 22464 KB Output is correct
4 Correct 100 ms 23360 KB Output is correct
5 Correct 87 ms 24768 KB Output is correct
6 Correct 95 ms 25656 KB Output is correct
7 Correct 88 ms 26960 KB Output is correct
8 Correct 97 ms 27360 KB Output is correct
9 Correct 97 ms 30032 KB Output is correct
10 Correct 86 ms 30416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 30416 KB Output is correct
2 Correct 8 ms 30416 KB Output is correct
3 Correct 8 ms 30416 KB Output is correct
4 Correct 11 ms 30416 KB Output is correct
5 Correct 10 ms 30416 KB Output is correct
6 Correct 10 ms 30416 KB Output is correct
7 Correct 13 ms 30416 KB Output is correct
8 Correct 10 ms 30416 KB Output is correct
9 Correct 10 ms 30416 KB Output is correct
10 Correct 10 ms 30416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 30624 KB Output is correct - 120000 bits used
2 Correct 105 ms 30736 KB Output is correct - 122000 bits used
3 Correct 100 ms 31256 KB Output is correct - 125000 bits used
4 Correct 97 ms 31256 KB Output is correct - 125000 bits used
5 Correct 158 ms 31256 KB Output is correct - 125000 bits used
6 Correct 115 ms 31256 KB Output is correct - 125000 bits used
7 Correct 105 ms 31256 KB Output is correct - 124828 bits used
8 Correct 92 ms 31256 KB Output is correct - 124910 bits used
9 Correct 96 ms 31256 KB Output is correct - 125000 bits used
10 Correct 92 ms 31256 KB Output is correct - 125000 bits used