#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 ] ;
void ComputeAdvice(int *c, int n, int r, int m){
for( int j = n - 1 ; j >= 0 ; j -- ){
v[ c[ j ] ].pb( j ) ;
}
int cs = 15 ;
if( r > 25000 ) cs = 18 ;
xx[ 0 ] = 1 ;
for( int i = 1 ; i <= 19 ; i ++ ) xx[ i ] = xx[ i - 1 ] * 2 ;
FOR( i , n ) cur[ i ] = -1 ;
FOR( i , r ) cur[ i ] = i ;
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 ) ;
}
FOR( i , n ){
int x = c[ i ] ;
if( cur[ x ] != -1 ){
v[ x ].pop_back() ;
FOR( i , cs ) WriteAdvice( 0 ) ;
continue ;
}
pair < int , int > p ;
p = *(--se.end() ) ;
se.erase( --se.end() ) ;
v[ x ].pop_back() ;
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 ] = cur[ p.s ] ;
int ps = cur[ p.s ] ;
cur[ p.s ] = -1 ;
FOR( j , cs ){
int y = ( ps & xx[ j ] ) ;
if( y == 0 ) WriteAdvice( 0 ) ;
else WriteAdvice( 1 ) ;
}
}
}
//void WriteAdvice(unsigned char a);
#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 xx[ 30 ] , cur[ N ] , invcur[ N ] ;
void Assist(unsigned char *a, int n, int r, int rr){
int cs = 15 ;
if( r > 25000 ) cs = 18 ;
xx[ 0 ] = 1 ;
for( int i = 1 ; i <= 19 ; i ++ ) xx[ i ] = xx[ i - 1 ] * 2 ;
FOR( i , n ) cur[ i ] = -1 ;
FOR( i , r ) cur[ i ] = i , invcur[ i ] = i ;
int pos = 0 ;
FOR( i , N ){
int x = GetRequest();
if( cur[ x ] != -1 ){
pos += cs ; continue ;
}
int nmb = 0 ;
FOR( j , cs ){
if( a[ pos ] == '1' ) nmb += xx[ j ] ;
pos ++ ;
}
PutBack( invcur[ nmb ] ) ;
cur[ invcur[ nmb ] ] = -1 ;
invcur[ nmb ] = x ;
cur[ x ] = nmb ;
}
}
//void PutBack(int T);
//
//int GetRequest();
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
5264 KB |
Error - Too many requests |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
6760 KB |
Error - Too many requests |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
196 ms |
17324 KB |
Error - Too many requests |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
5384 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
237 ms |
19940 KB |
Error - Too many requests |
2 |
Incorrect |
241 ms |
20020 KB |
Error - Too many requests |
3 |
Incorrect |
253 ms |
20308 KB |
Error - Too many requests |
4 |
Incorrect |
241 ms |
20164 KB |
Error - Too many requests |
5 |
Incorrect |
239 ms |
20428 KB |
Error - Too many requests |
6 |
Incorrect |
240 ms |
20184 KB |
Error - Too many requests |
7 |
Incorrect |
239 ms |
20180 KB |
Error - Too many requests |
8 |
Incorrect |
241 ms |
20160 KB |
Error - Too many requests |
9 |
Incorrect |
262 ms |
20332 KB |
Error - Too many requests |
10 |
Incorrect |
242 ms |
21376 KB |
Error - Too many requests |