답안 #363170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363170 2021-02-05T08:30:23 Z eric_xiao 최후의 만찬 (IOI12_supper) C++14
0 / 100
2500 ms 20204 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++)
    {
        cerr << "i = " << i << endl;
        last[C[i]] = i;
        for(auto y : nw)
        {
            cerr << y.F << "_" << y.S << endl;
        }
        cerr << endl;
        if(in[C[i]] == 1)
        {
            cerr << "one" << endl;
            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());

        cerr << "two" << endl;
        if(last[u->S] == -1)
        {
            st[u->S] = 1;
        }
        else
        {
            th[last[u->S]] = 1;
        }
        pii t = {*occ[C[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*2;i++)
    {
        cerr << int(A[i]) << ' ';
    }
   cerr << endl;
    for(i = 0;i < N;i++)
    {
        if(A[i] == 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;
      |             ^

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:12:11: warning: unused variable 'k' [-Wunused-variable]
   12 |     int i,k;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5728 KB Output is correct
2 Incorrect 32 ms 5608 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2582 ms 9436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2561 ms 17644 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2595 ms 8388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2547 ms 19820 KB Time limit exceeded
2 Execution timed out 2582 ms 20044 KB Time limit exceeded
3 Execution timed out 2588 ms 20096 KB Time limit exceeded
4 Execution timed out 2596 ms 20056 KB Time limit exceeded
5 Execution timed out 2594 ms 20104 KB Time limit exceeded
6 Execution timed out 2530 ms 20076 KB Time limit exceeded
7 Execution timed out 2596 ms 20204 KB Time limit exceeded
8 Execution timed out 2597 ms 20048 KB Time limit exceeded
9 Execution timed out 2587 ms 20096 KB Time limit exceeded
10 Execution timed out 2553 ms 20152 KB Time limit exceeded