#include "advisor.h"
#include <bits/stdc++.h>
#define lp(i,a,b) for(int i = a ; i < b ; i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
const int MAXN = 1e5+10 ;
const int inf = 1e9+10 ;
using namespace std ;
bool is_active[MAXN*2] , scaffold[MAXN] ;
vector<int> cores[MAXN] ;
int ptr[MAXN] , active[MAXN] ;
set<pii> s ;
int get_next(int cor)
{
if( ptr[cor] >= (int)cores[cor].size() ) return inf ;
return cores[cor][ ptr[cor]++ ] ;
}
void ComputeAdvice(int *C, int N, int K, int M)
{
lp(i,0,N) cores[ C[i] ].pb( i ) ;
lp(i,0,K) s.insert( mk( get_next(i) , i ) ) , scaffold[i] = true , active[i] = N+i ;
for(int i = 0 ; i < N ; i++ )
{
active[ C[i] ] = i ;
if( scaffold[ C[i] ] )
{
s.erase( s.find( mk( i , C[i] ) ) ) ;
s.insert( mk( get_next(C[i]) , C[i] ) ) ;
continue ;
}
auto par = *prev(s.end()) ;
s.erase( prev( s.end() ) ) ;
scaffold[ par.ss ] = false ;
scaffold[ C[i] ] = true ;
is_active[ active[par.ss] ] = true ;
get_next(C[i]) ;
s.insert( mk( get_next(C[i]) , C[i] ) ) ;
}
lp(i,0,K) WriteAdvice( is_active[N+i] ) ;
lp(i,0,N) WriteAdvice( is_active[i] ) ;
}
#include <bits/stdc++.h>
#include "assistant.h"
#define lp(i,a,b) for(int i = a ; i < b ; i++)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
const int MAXN = 1e5+10 ;
using namespace std ;
set<int> actives ;
bool scaff[MAXN] ;
void Assist(unsigned char *A, int N, int K, int R)
{
int idx = -1 ;
lp(i,0,K)
{
scaff[i] = true ;
if( A[++idx] ) actives.insert(i) ;
}
lp(i,0,N)
{
int x = GetRequest() ;
if( scaff[x] )
{
if( A[++idx] ) actives.insert( x ) ;
else continue ;
}
scaff[x] = true ;
int toErase = *actives.begin() ;
actives.erase( actives.begin() ) ;
scaff[ toErase ] = false ;
PutBack(toErase) ;
if( A[++idx] ) actives.insert(x) ;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
5376 KB |
Output is correct |
2 |
Incorrect |
11 ms |
5376 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
16 ms |
6272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
104 ms |
15088 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
5888 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
75 ms |
14712 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Incorrect |
142 ms |
17416 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Incorrect |
147 ms |
17648 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Incorrect |
134 ms |
17648 KB |
Error - Putting back a color when it is already on the scaffold |
5 |
Incorrect |
145 ms |
17648 KB |
Error - Putting back a color when it is already on the scaffold |
6 |
Incorrect |
135 ms |
17824 KB |
Error - Putting back a color when it is already on the scaffold |
7 |
Incorrect |
140 ms |
17520 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
154 ms |
17648 KB |
Error - Putting back a color when it is already on the scaffold |
9 |
Incorrect |
150 ms |
17904 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Incorrect |
118 ms |
19696 KB |
Error - Putting back a color when it is already on the scaffold |