제출 #928044

#제출 시각아이디문제언어결과실행 시간메모리
928044definitelynotmee최후의 만찬 (IOI12_supper)C++17
100 / 100
95 ms7672 KiB

#include "advisor.h"
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define O_O
using namespace std;
template <typename T>
using bstring = basic_string<T>;
template <typename T>
using matrix = vector<vector<T>>;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef double dbl;
typedef long double dbll;
const ll INFL = 4e18+25;
const int INF = 1e9+42;
const double EPS = 1e-7;
const int MOD = 998244353;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
const int MAXN = 1e6+1;

void ComputeAdvice(int *C, int N, int K, int M) {
    
    K = min(K,N);
    vector<int> advice(N+K,1);

    vector<int> last(N,-1);
    iota(last.begin(), last.begin()+K,0);

    vector<int> next(N+K,INF);

    for(int i = 0; i < N; i++){
        if(last[C[i]] != -1)
            next[last[C[i]]] = i+K;
        last[C[i]] = i+K;
    }

    last = vector<int>(N,-1);
    iota(last.begin(), last.begin()+K,0);

    set<pii, greater<pii>> scaff;

    for(int i = 0; i < K; i++){
        scaff.insert({next[i], i});
    }

    auto pop =[&](){
        pii cur = *scaff.begin();
        scaff.erase(scaff.begin());
        advice[cur.ss] = 0;
    };

    for(int i = 0; i < N; i++){
        if(last[C[i]] != -1 && scaff.count({i+K, last[C[i]]})){
            scaff.erase({i+K, last[C[i]]});
        } else {
            pop();
        }
        scaff.insert({next[i+K], i+K});
        last[C[i]] = i+K;
    }

    for(int i : advice)
        WriteAdvice(i);

}

#include "assistant.h"
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define O_O
using namespace std;
template <typename T>
using bstring = basic_string<T>;
template <typename T>
using matrix = vector<vector<T>>;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef double dbl;
typedef long double dbll;
const ll INFL = 4e18+25;
const int INF = 1e9+42;
const double EPS = 1e-7;
const int MOD = 998244353;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
const int MAXN = 1e6+1;


void Assist(unsigned char *A, int N, int K, int R) {
    vector<int> todelete;

    for(int i = 0; i < K; i++)
        if(A[i] == 0)
            todelete.push_back(i);
    
    set<int> scaff;

    for(int i = 0; i < K; i++)
        scaff.insert(i);
    
    for(int i = 0; i < N; i++){
        int cur = GetRequest();
        if(!scaff.count(cur)){
            
            scaff.insert(cur);
            
            scaff.erase(todelete.back());
            PutBack(todelete.back());
            todelete.pop_back();
        }
        if(A[i+K] == 0)
            todelete.push_back(cur);//, cerr << cur << " todelete" << endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...