답안 #328691

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
328691 2020-11-17T17:17:15 Z achibasadzishvili 최후의 만찬 (IOI12_supper) C++14
0 / 100
56 ms 13184 KB
#include "advisor.h"
#include<bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int L;
void write(ll x){
    //cerr << "Writing: " << x << '\n';
    for(int i=0; i<L; i++){
        //cerr << (x & 1) << '\n';
        WriteAdvice(char((x & 1) + int('0')));
        x /= 2;
    }
}
int AC[200005];
void ComputeAdvice(int *c, int n, int k, int m){
    ordered_set ord;
    set<pair<ll,ll> >st;
    set<pair<ll,ll> >::iterator it;
    set<ll>fr[n + 2];
    for(int i=1; i<=20; i++)
        if((1 << i) > k){
            L = i;
            break;
        }
//    cerr << "L: " <<L << '\n';
    for(int i=0; i<n; i++){
        fr[c[i]].insert(i);
    }
    for(int i=0; i<k; i++){
        AC[i] = 1;
        ord.insert(i);
        if(fr[i].size() == 0)
            st.insert(mp(n + 2 , i));
        else
            st.insert(mp((*fr[i].begin()) , i));
    }
    for(int i=0; i<n; i++){
        ll x = c[i];
        if(AC[x] == 1){
            st.erase(mp((*fr[x].begin()) , x));
            fr[x].erase(fr[x].begin());
            if(fr[x].size() == 0)
                st.insert(mp(n + 2 , x));
            else
                st.insert(mp((*fr[x].begin()) , x));
            continue;
        }
        else {
            fr[x].erase(i);
            it = st.end();
            it--;
            int num = (*it).s;
            AC[num] = 0;
            AC[x] = 1;
            int ind = ord.order_of_key(num);
            write(ind);
            ord.insert(x);
            ord.erase(num);
            st.erase(it);
            if(fr[x].size() == 0)
                st.insert(mp(n + 2 , x));
            else
                st.insert(mp((*fr[x].begin()) , x));
        }
    }
}
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll int
#define f first
#define s second
#define pb push_back
#include "assistant.h"
using namespace std;
int l = 0,ind = 0,ac[200005];
void Assist(unsigned char *A, int n, int k, int R){
//    cerr << "AAA" << A[0] << '\n';
    ordered_set ord;
    for(int i=1; i<=20; i++)
        if((1 << i) > k){
            l = i;
            break;
        }
    for(int i=0; i<k; i++){
        ord.insert(i);
        ac[i] = 1;
    }
    for(int i=0; i<n; i++){
        ll x = GetRequest();
        if(ac[x] == 1)continue;
        else {
            ll k = 1,num = 0;
            for(int i=ind; i<ind+l; i++){
                if(A[ind] == 1)num += k;
                k *= 2;
            }
            ind += l;
            ll p = (*ord.find_by_order(num));
        //    cerr << "OE: " << p << '\n';
            PutBack(p);
        //    cerr << "Back: " << p << " " << x << '\n';
            ac[p] = 0;
            ac[x] = 1;
            ord.erase(p);
            ord.insert(x);
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 968 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1892 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 10596 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1492 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 12684 KB Error - advice must be 0 or 1
2 Incorrect 51 ms 12644 KB Error - advice must be 0 or 1
3 Incorrect 52 ms 13064 KB Error - advice must be 0 or 1
4 Incorrect 52 ms 12900 KB Error - advice must be 0 or 1
5 Incorrect 56 ms 13184 KB Error - advice must be 0 or 1
6 Incorrect 53 ms 13056 KB Error - advice must be 0 or 1
7 Incorrect 49 ms 12900 KB Error - advice must be 0 or 1
8 Incorrect 52 ms 13028 KB Error - advice must be 0 or 1
9 Incorrect 54 ms 13064 KB Error - advice must be 0 or 1
10 Incorrect 51 ms 13056 KB Error - advice must be 0 or 1