#include "advisor.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
//#define int long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod = 1000000007 ;
const int mod1 = 998244353 ;
const int N = 2e5 + 10 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;
vector < int > v[ N ] ;
int xx[ 30 ] , cur[ N ] , app[ N ] ;
void ComputeAdvice(int *c, int n, int r, int m){
for( int j = n - 1 ; j >= 0 ; j -- ){
v[ c[ j ] ].pb( j ) ;
}
set < pair < int , int > > se ;
FOR( i , r ){
int pos = INT_MAX ;
if( v[ i ].size() != 0 ) pos = v[ i ][ v[ i ].size() - 1 ] ;
pair < int , int > p ;
p.f = pos ; p.s = i ;
se.insert( p ) ;
}
vector < int > ve ;
FOR( i , r ) ve.pb( 0 ) , app[ i ] = i , cur[ i ] = 1 ;
FOR( i , n ){
int x ; cin >> x ;
if( cur[ x ] != -1 ){
ve[ app[ x ] ] = 1 ;
se.erase( se.find( { v[ x ][ v[ x ].size() - 1 ] , x } ) ) ;
v[ x ].pop_back() ;
if( v[ x ].size() != 0 ) se.insert( { v[ x ][ v[ x ].size() - 1 ] , x } ) ;
else se.insert( { INT_MAX , x } ) ;
ve.pb( 0 ) ;
app[ x ] = ve.size() - 1 ;
continue ;
}
pair < int , int > p ;
p = *(--se.end() ) ;
se.erase( --se.end() ) ;
v[ x ].pop_back() ;
ve.pb( 0 ) ;
app[ x ] = ve.size() - 1 ;
int pos = INT_MAX ;
if( v[ x ].size() != 0 ) pos = v[ x ][ v[ x ].size() - 1 ] ;
pair < int , int > p1 ;
p1.f = pos ; p1.s = x ;
se.insert( p1 ) ;
cur[ x ] = 1 ;
cur[ p.s ] = -1 ;
}
for( auto x : ve ) WriteAdvice( x ) ;
}
//void WriteAdvice(unsigned char a);
//#include "grader.h"
#include "assistant.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
//#define int long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod = 1000000007 ;
const int mod1 = 998244353 ;
const int N = 2e5 + 10 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;
int pos[ N ] ;
void Assist(unsigned char *a, int n, int r, int rr){
set < int > act , non ;
int cnt = 0 ;
FOR( i , r ){
if( a[ i ] == 1 ) act.insert( i ) ;
else non.insert( i ) ;
pos[ i ] = i ;
cnt ++ ;
}
FOR( i , N ){
int x = GetRequest() ;
if( act.find( x ) != act.end() ){
pos[ x ] = cnt ;
if( a[ cnt ] == 0 ){
act.erase( act.find( x ) ) ;
non.insert( x ) ;
}
cnt ++ ;
continue ;
}
int X = *non.begin() ;
non.erase( non.begin() ) ;
PutBack( X ) ;
pos[ x ] = cnt ; cnt ++ ;
if( a[ pos[ x ] ] == 1 ) act.insert( x ) ;
else non.insert( x ) ;
}
}
//void PutBack(int T);
//
//int GetRequest();
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
9940 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
8 ms |
10760 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
22 ms |
16796 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
10268 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
23 ms |
17992 KB |
Execution killed with signal 6 |
2 |
Runtime error |
26 ms |
18252 KB |
Execution killed with signal 6 |
3 |
Runtime error |
28 ms |
18704 KB |
Execution killed with signal 6 |
4 |
Runtime error |
27 ms |
18584 KB |
Execution killed with signal 11 |
5 |
Runtime error |
25 ms |
18528 KB |
Execution killed with signal 6 |
6 |
Runtime error |
25 ms |
18576 KB |
Execution killed with signal 11 |
7 |
Runtime error |
24 ms |
18520 KB |
Execution killed with signal 6 |
8 |
Runtime error |
24 ms |
18644 KB |
Execution killed with signal 6 |
9 |
Runtime error |
28 ms |
18580 KB |
Execution killed with signal 11 |
10 |
Runtime error |
27 ms |
20824 KB |
Execution killed with signal 6 |