QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#209440#7565. Harumachi Kazeucup-team1325WA 1099ms20732kbC++174.1kb2023-10-10 15:04:272023-10-10 15:04:27

Judging History

你现在查看的是最新测评结果

  • [2023-10-10 15:04:27]
  • 评测
  • 测评结果:WA
  • 用时:1099ms
  • 内存:20732kb
  • [2023-10-10 15:04:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll; typedef unsigned long long ull;
const int inf = 1e9; const ll llnf = 4e18;

template< class Tp > void chkmax( Tp &x , Tp y ) { x = max( x , y ); }
template< class Tp > void chkmin( Tp &x , Tp y ) { x = min( x , y ); }

ull add( ull x , ull y ) { cout << "A " << x << " " << y << "\n"; cout.flush( ); ull z; cin >> z; return z; }
bool cmp( ull x , ull y ) { cout << "C " << x << " " << y << "\n"; cout.flush( ); ull z; cin >> z; return ( z == x ); }

void solve( ) {
	int n , m , e; cin >> n >> m >> e;
	vector< ull > a( n ); for( int i = 0; i <= n - 1; i ++ ) cin >> a[i];
	vector< ull > b( n ); for( int j = 0; j <= n - 1; j ++ ) cin >> b[j];
	vector< tuple< int , int , ull > > qry( m );
	for( int t = 0; t < m; t ++ ) {
		int opt; cin >> opt;
		if( opt == 1 ) { int t , i; ull x; cin >> t >> i >> x; qry[t] = make_tuple( ( t == 1 ) ? ( 0 ) : ( 1 ) , i - 1 , x ); }
		if( opt == 2 ) { int k; cin >> k; qry[t] = make_tuple( -1 , k , 0 ); }
	}

	vector< int > c( 8 ) , d( 8 );
	for( int p = 0; p < 8; p ++ ) {
		for( int t = 0; t <= 2; t ++ ) if( ( p >> t ) & 1 ) if( t <= e - 1 ) c[p] += ( 1 << t ) + ( 1 << ( e - t - 1 ) );
	}
	for( int q = 0; q < 8; q ++ ) {
		for( int t = 3; t <= 5; t ++ ) if( ( q >> t ) & 1 ) if( t <= e - 1 ) d[q] += ( 1 << t ) + ( 1 << ( e - t - 1 ) );
		for( int t = 6; t <= e - 7; t ++ ) d[q] += ( 1 << t );
		d[q] += 65536 - ( 1 << e );
	}

	#define ls( o ) 2 * o
	#define rs( o ) 2 * o + 1

	struct segtree {
		vector< ull > tree;
		void pushup( int o ) { tree[o] = add( tree[ls( o )] , tree[rs( o )] ); }

		segtree( ) { }
		segtree( vector< ull > a ) {
			assert( ( int ) a.size( ) == 65536 );
			auto build = [&] ( auto build , int o , int L , int R ) -> void {
				if( L == R ) return tree[o] = a[L] , void( );
				else { int M = ( L + R ) / 2; build( build , ls( o ) , L , M ) , build( build , rs( o ) , M + 1 , R ); pushup( o ); }
			} ; tree = vector< ull >( 2 * 65536 ); build( build , 1 , 0 , 65535 );
		}
		void set( int i , ull ai ) {
			auto dfs = [&] ( auto dfs , int o , int L , int R ) -> void {
				if( L == i && R == i ) return tree[o] = ai , void( );
				else { int M = ( L + R ) / 2; ( i <= M ) ? ( dfs( dfs , ls( o ) , L , M ) ) : ( dfs( dfs , rs( o ) , M + 1 , R ) ); pushup( o ); }
			} ; dfs( dfs , 1 , 0 , 65535 );
		}
	} ;
	auto getans = [&] ( const segtree &A , const segtree &B ) -> ull {
		int oA = 1 , oB = 1; ull sA = 0 , sB = 0;
		for( int f = 15; f >= 0; f -- ) {
			if( !f ) {
				int tA = add( sA , A.tree[oA] ) , tB = add( sB , B.tree[oB] );
				return ( cmp( tA , tB ) ? tA : tB );
			} else {
				int tA = add( sA , A.tree[ls( oA )] ) , tB = add( sB , B.tree[ls( oB )] );
				if( cmp( tA , tB ) ) sA = tA , oA = rs( oA ) , oB = ls( oB );
				else sB = tB , oA = ls( oA ) , oB = rs( oB );
			}
		}
	} ;

	vector< segtree > C( 8 ) , D( 8 );
	for( int p = 0; p < 8; p ++ ) {
		vector< ull > ap( 65536 , 0 );
		for( int i = 0; i <= n - 1; i ++ ) if( i + c[p] <= 65535 ) ap[i + c[p]] = a[i];
		C[p] = segtree( ap );
	}
	for( int q = 0; q < 8; q ++ ) {
		vector< ull > bq( 65536 , 0 );
		for( int j = 0; j <= n - 1; j ++ ) if( j + d[q] <= 65535 ) bq[j + d[q]] = b[j];
		D[q] = segtree( bq );
	}

	vector< ull > ans;
	for( int t = 0; t < m; t ++ ) {
		if( get< 0 >( qry[t] ) == 0 ) {
			int i = get< 1 >( qry[t] ); ull ai = get< 2 >( qry[t] );	
			for( int p = 0; p < 8; p ++ ) if( i + c[p] <= 65535 ) C[p].set( i + c[p] , ai );
		} else if( get< 1 >( qry[t] ) == 1 ) {
			int j = get< 1 >( qry[t] ); ull bj = get< 2 >( qry[t] );
			for( int q = 0; q < 8; q ++ ) if( j + d[q] <= 65535 ) D[q].set( j + d[q] , bj );
		} else {
			int k = get< 1 >( qry[t] ); bool find = false;
			for( int p = 0; p < 8; p ++ ) for( int q = 0; q < 8; q ++ ) if( !find && c[p] + d[q] + k == 65535 ) find = true , ans.emplace_back( getans( C[p] , D[q] ) );
			if( !find ) assert( 0 );
		}
	}
	for( ull res : ans ) cout << res << " "; cout << "\n";
}

int main( ) {
	ios::sync_with_stdio( 0 ), cin.tie( 0 ), cout.tie( 0 );
	int T = 1; while( T -- ) solve( ); return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1099ms
memory: 20732kb

input:

2 3 2
288230376151711744 864691128455135232
1441151880758558720 2017612633061982208
2 3
1 2 2 2594073385365405696
2 3
1152921504606846976
0
1152921504606846976
0
0
0
1152921504606846976
0
0
0
0
0
0
0
1152921504606846976
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1152921504606846976
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

output:

A 288230376151711744 864691128455135232
A 0 0
A 1152921504606846976 0
A 0 0
A 0 0
A 0 0
A 1152921504606846976 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 1152921504606846976 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 0 0
A 1152921504606846976 0
A 0 0
A ...

result:

wrong answer 1st lines differ - expected: '2', found: ''