답안 #236681

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236681 2020-06-02T19:46:27 Z oscarsierra12 최후의 만찬 (IOI12_supper) C++14
0 / 100
115 ms 18656 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 ( 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 ;
        assert ( used[co.front()] ) ;
        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] ;
                           ~~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 5376 KB Output is correct
2 Runtime error 11 ms 5376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 6912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 84 ms 15584 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 5888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 103 ms 18624 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 104 ms 18656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 107 ms 18400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 104 ms 18392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 115 ms 18656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 102 ms 18400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 103 ms 18400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 102 ms 18656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 101 ms 18400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 100 ms 18144 KB Execution killed with signal 11 (could be triggered by violating memory limits)