제출 #236680

#제출 시각아이디문제언어결과실행 시간메모리
236680oscarsierra12최후의 만찬 (IOI12_supper)C++14
0 / 100
104 ms18416 KiB
#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 ( toen[i]  ) ;
}

#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 ;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

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 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...