답안 #363115

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363115 2021-02-05T05:06:41 Z eric_xiao 최후의 만찬 (IOI12_supper) C++14
0 / 100
180 ms 21800 KB
#include<bits/stdc++.h>
#include "advisor.h"
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
int st[100009],th[100009],in[100009],last[100009];
set<int> occ[100009];
set<pii> nw;
const int inf = 1000000;
void ComputeAdvice(int *C, int N, int K, int M) {
    int i,j,k;
    for(i = 0;i < N;i++)
    {
        occ[C[i]].insert(i);
        last[i] = -1;
    }
    for(i = 0;i < N;i++)
    {
        occ[i].insert(inf);
    }
    for(i = 0;i < K;i++)
    {
        in[i] = 1;
        nw.insert({*occ[i].begin(),i});
    }
    for(i = 0;i < N;i++)
    {
        last[C[i]] = i;
        if(in[C[i]] == 1)
        {
            auto p = nw.lower_bound({i,C[i]});
            pii t = {*occ[i].upper_bound(i),C[i]};
            nw.erase(p);
            nw.insert(t);
            continue;
        }
        auto u = prev(nw.end());
        if(last[u->S] == -1)
        {
            st[u->S] = 1;
        }
        else
        {
            th[last[u->S]] = 1;
        }
        pii t = {*occ[i].upper_bound(i),C[i]};
        nw.erase(u);
        nw.insert(t);
    }
    for(auto x : nw)
    {
        if(last[x.S] == -1)
        {
            st[x.S] = 1;
        }
        else
        {
            th[last[x.S]] = 1;
        }
    }
    for(i = 0;i < N;i++)
    {
        if(st[i] == 0)WriteAdvice(0);
        else WriteAdvice(1);
    }
    for(i = 0;i < N;i++)
    {
        if(th[i] == 0)WriteAdvice(0);
        else WriteAdvice(1);
    }
}
#include<bits/stdc++.h>
#include "assistant.h"
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
set<int> ok;
int C[100009];
set<int> inn;
void Assist(unsigned char *A, int N, int K, int R) {
    int i,k;
    for(i = 0;i < N;i++)
    {
        cin >> k;
        if(k == 1 && i < k)
        {
            ok.insert(i);
        }
    }
    for(i = 0;i < K;i++)inn.insert(i);
    for(i = 0;i < N;i++)
    {
        C[i] = GetRequest();
        if(!inn.count(C[i]))
        {
            PutBack((int)(*ok.begin()));
            inn.erase(*ok.begin());
            ok.erase(*ok.begin());
            inn.insert(C[i]);
        }
        if(A[N+i] == 1) ok.insert(C[i]);
        if(A[N+i] == 0 && ok.count(C[i])) ok.erase(C[i]);
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:13:11: warning: unused variable 'j' [-Wunused-variable]
   13 |     int i,j,k;
      |           ^
advisor.cpp:13:13: warning: unused variable 'k' [-Wunused-variable]
   13 |     int i,j,k;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 5348 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 6972 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 135 ms 18476 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 6300 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 164 ms 20920 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 168 ms 21428 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 164 ms 21460 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 180 ms 21800 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 168 ms 21460 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 178 ms 21732 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 177 ms 21460 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 164 ms 21524 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 172 ms 21460 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 168 ms 21520 KB Error - Putting back a color that is not on the scaffold