QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#410319 | #7517. Flying Ship Story | Sorting | WA | 212ms | 3564kb | C++20 | 2.2kb | 2024-05-13 21:24:26 | 2024-05-13 21:24:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair < int , int > pii ;
typedef vector < int > vi ;
#define fi first
#define se second
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
pii best[ 32 ][ 2 ][ 2 ] ;
int query ( int x , int y ) {
int ret = 0 ;
for ( int bit = 0 ; bit < 30 ; ++ bit ) {
int wh = 0 ;
if ( ( x & ( 1 << bit ) ) == 0 ) { wh = 1 ; }
if ( best[ bit ][ wh ][ 0 ].se == y ) {
ret = max ( ret , best[ bit ][ wh ][ 1 ].fi ) ;
}
else {
ret = max ( ret , best[ bit ][ wh ][ 0 ].fi ) ;
}
}
return ret ;
}
void add ( int x , int y , int w ) {
for ( int bit = 0 ; bit < 30 ; ++ bit ) {
int wh = 0 ;
if ( ( x & ( 1 << bit ) ) > 0 ) { wh = 1 ; }
if ( best[ bit ][ wh ][ 0 ].se == y ) {
best[ bit ][ wh ][ 0 ].fi = max ( best[ bit ][ wh ][ 0 ].fi , w ) ;
}
else if ( best[ bit ][ wh ][ 1 ].se == y ) {
best[ bit ][ wh ][ 1 ].fi = max ( best[ bit ][ wh ][ 1 ].fi , w ) ;
}
else {
if ( best[ bit ][ wh ][ 0 ].fi < w ) {
best[ bit ][ wh ][ 1 ] = best[ bit ][ wh ][ 0 ] ;
best[ bit ][ wh ][ 0 ] = { w , y } ;
}
else if ( best[ bit ][ wh ][ 1 ].fi < w ) {
best[ bit ][ wh ][ 1 ] = { w , y } ;
}
}
}
}
void solve ( ) {
int q ; cin >> q ;
int lst = 0 ;
while ( q -- ) {
int type ; cin >> type ;
int x , y , w ;
if ( type == 1 ) {
cin >> x >> y >> w ;
x ^= lst , y ^= lst , w ^= lst ;
add ( x , y , w ) ;
}
else {
cin >> x >> y ;
x ^= lst , y ^= lst ;
lst = query ( x , y ) ;
cout << lst << "\n" ;
}
}
}
int main ( ) {
ios_base :: sync_with_stdio ( false ) ;
cin.tie ( NULL ) ;
int t = 1 ; // cin >> t ;
while ( t -- ) { solve ( ) ; }
return 0 ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3476kb
input:
5 1 2 3 1 1 4 5 2 2 2 2 2 3 7 2 3 4
output:
2 1 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 212ms
memory: 3564kb
input:
1000000 2 370943499 431961772 1 1 1 11995570 2 37566858 838793045 1 11995571 11995569 908148975 2 11995571 11995571 1 1 3 716821068 2 67877937 3 1 11995571 11995571 771898489 2 38381714 99749723 1 915818844 915818847 729541681 2 592361351 915818846 1 783627722 783627722 639375021 2 102203700 8636489...
output:
0 11995570 0 11995570 915818845 783627723 915818845 0 0 915818845 0 783627723 0 904468304 904468304 904468304 915818845 904468304 915818845 904468304 915818845 0 904468304 0 915818845 915818845 0 0 915818845 915818845 0 921710773 0 921710773 921710773 921710773 309786171 921710773 921710773 92171077...
result:
wrong answer 35th lines differ - expected: '998138906', found: '921710773'