Submission #236671

# Submission time Handle Problem Language Result Execution time Memory
236671 2020-06-02T19:31:41 Z oscarsierra12 Last supper (IOI12_supper) C++14
0 / 100
64 ms 19928 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;

vector <int> co[100010] ;
int nxt[200010];
int used[200010] ;
int toen[200010] ;

void ComputeAdvice(int *C, int N, int K, int M) {
    vector <int> cur ;
    for ( int i = 0 ; i < K ; ++i ) cur.push_back ( i ) ;
    for ( int i = 0 ; i < N ; ++i ) cur.push_back ( C[i] ) ;
    for ( int i = 0 ; i < K + N ; ++i )
        co[cur[i]].push_back ( i ) ;
    for ( int i = 0 ; i < N ; ++i ) {
        co[i].push_back ( N+K ) ;
        for ( int j = 0 ; j + 1 < co[i].size() ; ++j ) nxt[co[i][j]] = co[i][j+1] ;
    }
    priority_queue<pair<int,int> > pq ;
    for ( int i = 0 ; i < K ; ++i ) pq.push ( make_pair(nxt[i],i) ), used[i] = 1 ;
    for ( int i = K ; i < N+K ; ++i ) {
        if ( used[cur[i]] ) continue ;
        pair<int,int> lst = make_pair(0,0) ;
        while ( lst.first < i ) {
            lst = pq.top() ;
            pq.pop() ;
            pq.push ( make_pair(nxt[lst.first],lst.first) ) ;
        }
        pq.push ( make_pair(nxt[i], i) ) ;
        toen[lst.second] = 1 ;
        used[cur[i]] = 1 ;
        used[cur[lst.first]] = 0;
    }
    for ( int i = 0 ; i < N+K ; ++i ) WriteAdvice ( char(toen[i] + '0') ) ;
}
#include "assistant.h"
#include <bits/stdc++.h>

using namespace std ;

int used[200010] ;
queue <int> co ;

void Assist(unsigned char *A, int N, int K, int R) {
    for ( int i = 0 ; i < K ; ++i ) {
        used[i] = 1 ;
        if (A[i] == '1' ) co.push ( i ) ;
    }
    for ( int i = K ; i < K+N ; ++i ) {
        int add = GetRequest() ;
        if ( A[i] == '1' ) co.push ( add ) ;
        if ( used[add] ) continue ;
        PutBack ( co.front() ) ;
        used[co.front()] = 0 ;
        co.pop() ;
        used[add] = 1 ;
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:19:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for ( int j = 0 ; j + 1 < co[i].size() ; ++j ) nxt[co[i][j]] = co[i][j+1] ;
                           ~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 5376 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 6912 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 16352 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 6144 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 19680 KB Error - advice must be 0 or 1
2 Incorrect 56 ms 19680 KB Error - advice must be 0 or 1
3 Incorrect 56 ms 19680 KB Error - advice must be 0 or 1
4 Incorrect 57 ms 19928 KB Error - advice must be 0 or 1
5 Incorrect 54 ms 19680 KB Error - advice must be 0 or 1
6 Incorrect 54 ms 19680 KB Error - advice must be 0 or 1
7 Incorrect 54 ms 19688 KB Error - advice must be 0 or 1
8 Incorrect 55 ms 19680 KB Error - advice must be 0 or 1
9 Incorrect 56 ms 19688 KB Error - advice must be 0 or 1
10 Incorrect 56 ms 19424 KB Error - advice must be 0 or 1