QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#422867#1963. Squid GamedengziyueAC ✓0ms3960kbC++141016b2024-05-27 19:55:592024-05-27 19:56:01

Judging History

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

  • [2024-05-27 19:56:01]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3960kb
  • [2024-05-27 19:55:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
long long a[5];
int p[5];
vector<pair<int,int>>ans;
inline void upd(int x,int y){
	a[x]-=a[y]; a[y]*=2; ans.push_back({x,y});
}
bool check(){
	if(a[1]==0||a[2]==0||a[3]==0)return true;
	for(int i=1;i<=3;++i){
		for(int j=i+1;j<=3;++j){
			if(a[i]==a[j]){upd(i,j); return true;}
		}
	}
	return false;
}
int main(){
	#ifndef ONLINE_JUDGE
	freopen("QOJ1963_1.in","r",stdin);
	freopen("QOJ1963_1.out","w",stdout);
	#endif
	scanf("%lld%lld%lld",a+1,a+2,a+3);
	p[1]=1; p[2]=2; p[3]=3;
	for(int ca=1;ca<=10;++ca){
		if(check())break;
		sort(p+1,p+4,[](int x,int y){return a[x]<a[y];});
		upd(p[3],p[2]);
	}
	while(true){
		if(check())break;
		sort(p+1,p+4,[](int x,int y){return a[x]<a[y];});
		int w=a[p[2]]/a[p[1]];
		while(a[p[1]]<=a[p[2]]){
			if(check())break;
			if(w%2==0)upd(p[3],p[1]);
			else upd(p[2],p[1]);
			w>>=1;
		}
	}
	printf("%d\n",(int)ans.size());
	for(auto p:ans)printf("%d %d\n",p.first,p.second);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 2 3

output:

2
3 2
1 3

result:

ok good plan

Test #2:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

1 4 6

output:

13
3 2
2 3
2 3
3 2
3 2
2 3
2 3
3 2
3 2
2 3
2 1
2 1
1 3

result:

ok good plan

Test #3:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

3 4 8

output:

14
3 2
2 3
3 2
2 3
3 2
2 3
3 2
2 3
3 2
2 3
2 1
3 2
1 2
1 2

result:

ok good plan

Test #4:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

2 5 8

output:

13
3 2
2 3
2 3
3 1
3 1
1 3
3 1
3 1
1 3
3 1
3 2
3 2
1 2

result:

ok good plan

Test #5:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

3 8 12

output:

18
3 2
2 3
2 3
3 2
3 2
2 3
2 3
3 2
3 2
2 3
2 1
3 1
1 3
1 3
2 3
3 2
1 2
1 2

result:

ok good plan

Test #6:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

5 9 13

output:

15
3 2
2 1
2 1
1 3
1 3
3 1
1 3
3 1
1 3
3 1
1 2
3 2
1 3
2 3
2 3

result:

ok good plan

Test #7:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

4 15 26

output:

13
3 2
2 3
3 2
2 1
2 1
2 1
1 2
1 2
2 3
2 3
2 1
3 1
1 3

result:

ok good plan

Test #8:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

8 27 46

output:

16
3 2
2 3
3 2
2 1
2 1
2 1
1 2
1 2
2 1
1 2
1 3
1 3
2 1
2 1
3 1
1 3

result:

ok good plan

Test #9:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

27 35 43

output:

25
3 2
2 1
1 2
2 1
2 1
2 1
1 2
1 2
1 2
2 1
2 3
1 3
2 3
3 2
3 2
1 2
3 1
3 1
3 1
2 3
2 3
2 3
2 3
1 3
1 3

result:

ok good plan

Test #10:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

8 35 62

output:

25
3 2
2 3
3 2
2 3
2 3
2 3
3 2
3 2
3 2
2 3
2 1
3 1
2 1
1 2
1 2
3 2
1 3
1 3
1 3
2 1
2 1
2 1
2 1
3 1
1 3

result:

ok good plan

Test #11:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

66 95 98

output:

8
3 2
2 1
1 2
2 1
2 1
2 1
2 1
1 2

result:

ok good plan

Test #12:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

109 167 289

output:

20
3 2
2 3
3 2
2 1
2 1
1 2
1 2
2 1
1 2
2 1
2 3
1 3
2 1
2 1
3 1
2 3
1 3
1 3
1 3
1 3

result:

ok good plan

Test #13:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

269 380 398

output:

25
3 2
2 1
1 2
2 1
2 1
2 1
2 1
1 2
2 1
1 2
1 3
1 3
1 3
2 3
1 2
1 2
3 2
1 2
3 2
1 3
1 3
1 3
2 3
2 3
2 3

result:

ok good plan

Test #14:

score: 0
Accepted
time: 0ms
memory: 3932kb

input:

233 364 480

output:

20
3 2
2 1
2 1
1 3
1 3
1 3
3 1
3 1
3 1
1 3
1 2
3 2
3 2
1 3
1 3
2 3
1 3
2 3
2 3
2 3

result:

ok good plan

Test #15:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

1098 1376 1489

output:

23
3 2
2 1
1 2
2 1
2 1
1 2
2 1
2 1
1 2
2 3
3 1
2 1
3 1
2 3
2 3
2 3
1 3
2 1
2 1
3 1
2 1
2 1
1 3

result:

ok good plan

Test #16:

score: 0
Accepted
time: 0ms
memory: 3960kb

input:

10035 10338 10444

output:

80
3 2
2 1
1 2
2 1
1 2
2 1
2 1
1 2
1 2
1 2
2 3
1 3
1 3
2 3
1 3
2 3
1 3
2 1
3 1
2 1
3 1
2 1
2 1
3 1
3 1
1 3
1 3
1 3
1 3
2 3
1 3
1 3
2 3
2 3
1 2
1 2
1 2
1 2
3 2
1 2
3 2
1 2
1 2
2 1
3 1
3 1
3 1
2 1
3 1
3 1
2 1
3 1
3 1
2 3
2 3
2 3
2 3
1 3
2 3
1 3
1 3
1 3
2 3
1 3
2 3
2 3
3 2
3 2
3 2
3 2
3 2
1 2
1 2
3 2
3...

result:

ok good plan

Test #17:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

100010 100200 100227

output:

50
3 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 3
1 3
1 3
2 3
1 3
2 3
2 3
1 3
1 3
1 3
2 3
2 3
1 3
3 1
2 1
3 1
3 1
3 1
2 1
3 1
2 1
3 1
3 1
2 1
3 1
2 1
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
1 2
1 2
1 2
1 2

result:

ok good plan

Test #18:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

1000000 1000235 1000288

output:

80
3 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 3
1 3
1 3
1 3
1 3
2 3
1 3
2 3
2 3
2 3
2 3
2 3
1 3
1 3
2 3
1 2
1 2
3 2
3 2
3 2
3 2
1 2
3 2
3 2
1 2
3 2
3 2
1 2
3 2
3 2
3 2
1 2
3 1
2 1
3 1
3 1
2 1
3 1
3 1
3 1
2 1
3 1
2 1
2 1
2 1
2 1
3 1
2 1
3 1
3 1
2 3
2 3
2 3
2 3
2 3
2 3
2 3
2 3
2 3
2 3
2 3
2 3
2 3
2 3
2...

result:

ok good plan

Test #19:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

10000011 10000314 10000358

output:

74
3 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 3
1 3
2 3
2 3
2 3
2 3
2 3
2 3
1 3
1 3
1 3
1 3
1 3
1 3
1 3
2 3
2 3
2 3
3 2
3 2
1 2
1 2
3 2
3 2
1 2
1 2
3 2
3 2
1 2
1 2
3 2
3 2
1 2
1 2
3 2
3 2
1 2
1 2
1 2
3 2
2 3
1 3
2 3
1 3
2 3
1 3
2 3
2 3
2 3
1 3
1 3
2 3
2 3
2 3
1 3
1 3
1 3
2 3
2 3
1 3
2 3
2 3
2 3
1 3

result:

ok good plan

Test #20:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

100000057 100000244 100000402

output:

172
3 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 3
1 3
2 3
1 3
1 3
2 3
2 3
2 3
2 3
1 3
1 3
2 3
1 3
2 3
1 3
2 3
2 3
1 3
1 3
2 3
3 2
3 2
1 2
1 2
3 2
3 2
1 2
1 2
1 2
3 2
3 2
3 2
1 2
1 2
3 2
1 2
3 2
3 2
3 2
1 2
1 2
3 1
2 1
3 1
2 1
2 1
2 1
2 1
3 1
2 1
2 1
2 1
2 1
3 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
3 1
1 3
1 3
...

result:

ok good plan

Test #21:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

1 1000000 1000000000

output:

35
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
2 3
3 1
3 1
3 1
3 1
3 1
3 1
2 1
2 1
2 1
2 1
3 1
3 1
2 1
2 1
2 1
2 1
3 1
2 1
2 1
2 1
2 1
3 1
2 1
3 1
1 2

result:

ok good plan

Test #22:

score: 0
Accepted
time: 0ms
memory: 3956kb

input:

1024 65536 536870912

output:

27
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
1 2

result:

ok good plan

Test #23:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

6 268435456 536870912

output:

63
3 2
2 3
3 2
2 3
3 2
2 3
3 2
2 3
3 2
2 3
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 1
2 1
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
1 2
1 2

result:

ok good plan

Test #24:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

7 16777217 536870909

output:

56
3 2
3 2
3 2
3 2
3 2
2 3
2 3
2 3
2 3
2 3
3 1
3 1
2 1
3 1
3 1
2 1
2 1
2 1
3 1
2 1
3 1
3 1
2 1
3 1
3 1
2 1
3 1
3 1
2 1
3 1
3 1
2 1
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
1 2
1 2
1 2

result:

ok good plan

Test #25:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

24223 44594 72242

output:

57
3 2
2 3
2 3
3 1
3 1
1 3
3 1
1 3
1 3
3 1
2 3
2 3
2 3
2 3
2 3
1 2
3 2
3 2
3 2
1 2
3 2
3 2
3 2
3 2
2 3
1 3
1 3
2 3
2 3
1 3
1 3
2 3
1 3
2 3
1 2
3 2
1 2
3 2
1 2
3 2
1 2
3 2
1 2
3 2
3 2
1 3
1 3
1 3
1 3
1 3
1 3
1 3
1 3
1 3
1 3
2 3
2 3

result:

ok good plan

Test #26:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

123441 146831 150393

output:

51
3 2
2 1
1 2
2 1
2 1
1 2
2 1
1 2
1 2
1 2
2 3
2 3
2 3
1 3
2 3
2 3
1 2
3 2
3 2
3 2
3 2
1 2
1 2
2 1
2 1
3 1
3 1
2 1
2 1
2 1
3 1
1 3
1 3
2 3
2 3
1 3
2 3
1 3
2 3
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
2 3

result:

ok good plan

Test #27:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

1017604 1044219 1047264

output:

140
3 2
2 1
1 2
2 1
1 2
2 1
2 1
1 2
1 2
1 2
2 3
2 3
2 3
1 3
1 3
1 3
1 3
1 3
2 3
3 2
3 2
3 2
1 2
1 2
1 2
3 2
3 2
3 2
1 2
1 2
2 1
3 1
3 1
3 1
2 1
3 1
2 1
2 1
3 1
3 1
2 1
3 1
2 1
2 1
3 1
2 3
1 3
1 3
1 3
2 3
1 3
2 3
2 3
1 3
2 3
1 3
1 3
2 3
1 3
2 3
3 2
1 2
3 2
3 2
1 2
1 2
3 2
3 2
1 2
1 2
1 2
3 2
3 2
1 2
...

result:

ok good plan

Test #28:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

10023437 10049857 10053253

output:

89
3 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 3
2 3
2 3
1 3
1 3
1 3
2 3
1 3
2 3
2 3
1 3
1 3
2 1
2 1
3 1
2 1
3 1
3 1
3 1
2 1
2 1
2 1
2 1
2 1
3 1
2 3
2 3
2 3
1 3
1 3
1 3
1 3
1 3
1 3
2 3
2 3
1 2
3 2
1 2
3 2
1 2
3 2
3 2
1 2
3 2
1 2
1 2
1 2
3 2
1 3
1 3
1 3
1 3
1 3
2 3
1 3
2 3
2 3
1 3
2 3
1 3
2 3
2 3
1 2
1...

result:

ok good plan

Test #29:

score: 0
Accepted
time: 0ms
memory: 3948kb

input:

100010076 100034479 100039408

output:

187
3 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
2 3
2 3
2 3
2 3
2 3
1 3
2 3
2 3
2 3
1 3
2 3
1 3
2 3
1 3
2 3
1 2
1 2
1 2
3 2
1 2
3 2
1 2
3 2
1 2
1 2
1 2
1 2
1 2
1 2
3 2
3 2
1 2
2 1
3 1
3 1
2 1
2 1
3 1
2 1
3 1
3 1
2 1
3 1
2 1
2 1
3 1
3 1
2 1
3 1
1 3
2 3
2 3
1 3
2 3
2 3
2 3
2 3
2 3
2 3
1 3
2 3
1 3
1 3
1 3
...

result:

ok good plan

Test #30:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

100021199 100049225 100065369

output:

128
3 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
1 2
2 1
2 3
1 3
2 3
1 3
1 3
1 3
1 3
2 3
1 3
2 3
1 3
2 3
2 3
3 2
1 2
1 2
1 2
3 2
3 2
3 2
1 2
3 2
3 2
1 2
1 2
3 2
3 2
3 2
2 3
1 3
1 3
1 3
2 3
1 3
2 3
1 3
1 3
2 3
1 3
1 3
1 3
2 3
1 3
1 3
2 3
3 2
3 2
1 2
3 2
1 2
3 2
3 2
1 2
3 2
1 2
1 2
1 2
3 2
1 2
1 2
3 1
2 1
3 1
3 1
...

result:

ok good plan