#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 ;
}
}
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 |
Incorrect |
10 ms |
5376 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
7168 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
83 ms |
15600 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
6144 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
99 ms |
18400 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
99 ms |
18528 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
107 ms |
18400 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
99 ms |
18392 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
104 ms |
18464 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
99 ms |
18664 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
99 ms |
18400 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
99 ms |
18416 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
99 ms |
18400 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
103 ms |
18144 KB |
Error - Putting back a color that is not on the scaffold |