QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#759755#9351. Game Store275307894a#TL 0ms3920kbC++141.6kb2024-11-18 11:49:562024-11-18 11:49:57

Judging History

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

  • [2024-11-18 11:49:57]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3920kb
  • [2024-11-18 11:49:56]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=5e3+5,M=N*4+5,K=1000+5,mod=1e8+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n;
ll tot;
using info=array<char,60>;
info operator +(const info &A,const info &B){
	info C;
	for(int i=0;i<60;i++) C[i]=(A[i]+B[i])%3;
	return C;
}
info f[60];ll fw[60];
void ins(info x,ll w){
	for(int i=59;~i;i--) if(x[i]){
		if(fw[i]<w) tot+=w-fw[i],swap(w,fw[i]),swap(x,f[i]);
		while(x[i]) x=x+f[i];
	}
}
void Solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		ll x,y;scanf("%lld%lld",&x,&y);
		x^=tot;y^=tot;
		gdb(x,y);
		info w;
		for(int j=0;j<60;j++) w[j]=x>>j&1;
		ins(w,y);
		printf("%lld\n",tot);
	}
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3920kb

input:

3
1 4
6 7
4 13

output:

4
7
14

result:

ok 3 lines

Test #2:

score: -100
Time Limit Exceeded

input:

500000
395134631858718935 964539556
125290790696511447 743741881
68785955678986648 1867726875
774218610629433714 1107843806
251011758189826329 3218789432
712376502291877860 3368474950
237512969552427655 3307057592
26026853208103063 3366794857
904189246433646740 3824475130
105677592268903953 50111856...

output:

964539556
1319559617
1889305499
2737921248
3223119288
3371639478
3605116356
4113447281
4496890876
5146597364
5443005741
5560684788
6532334449
7521134451
8336539770
8705245338
9014268525
9265374719
9381614536
9559254162
10004316290
10462314640
10662416153
10955313276
11748683855
12256749782
129943566...

result: