QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617621 | #1963. Squid Game | untitledtwo# | AC ✓ | 0ms | 3660kb | C++17 | 1.4kb | 2024-10-06 16:26:09 | 2024-10-06 16:26:11 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define up(i,x,y) for(int i=x,i##E=y;i<=i##E;i++)
#define pu(i,x,y) for(int i=x,i##E=y;i>=i##E;i--)
#define rd(x) scanf("%lld",&x)
#define opl(x) printf("%lld",x)
#define mc cerr<<"qwq\n"
#define edl puts("")
using namespace std;
int a[10];
vector<pair<int,int>>v;
void pour(int i,int j)
{
assert(a[i]>=a[j]);
a[i]-=a[j];
a[j]*=2;
v.push_back(make_pair(i,j));
}
void solve()
{
int tim=1000000;
while(tim--)
{
int p,q,r;
if(a[1]<=a[2]&&a[1]<=a[3])p=1;
else if(a[2]<=a[1]&&a[2]<=a[3])p=2;
else if(a[3]<=a[1]&&a[3]<=a[2])p=3;
if(p!=1&&a[1]>=a[2]&&a[1]>=a[3])r=1;
if(p!=2&&a[2]>=a[1]&&a[2]>=a[3])r=2;
if(p!=3&&a[3]>=a[1]&&a[3]>=a[2])r=3;
q=6-p-r;
//p=min
//q=mid
//r=max
int qwq=(a[q]/a[p]);
// mc;
for(int i=0;i<=30;i++)
{
if(qwq/(1<<(i+1))==0)break;
if(qwq&(1<<i))
{
pour(q,p);
}
else
{
pour(r,p);
}
}
// cout<<a[1]<<" "<<a[2]<<" "<<a[3];edl;
pour(q,p);
// cout<<a[1]<<" "<<a[2]<<" "<<a[3];edl;
if(min(a[1],min(a[2],a[3]))==0)return;
}
}
signed main()
{
cin>>a[1]>>a[2]>>a[3];
solve();
assert(v.size()<=1000);
cout<<v.size();
puts("");
for(auto to:v)
{
cout<<to.first<<" "<<to.second;
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
1 2 3
output:
2 3 1 2 1
result:
ok good plan
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
1 4 6
output:
3 3 1 3 1 2 1
result:
ok good plan
Test #3:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
3 4 8
output:
4 2 1 3 2 1 2 1 2
result:
ok good plan
Test #4:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
2 5 8
output:
5 3 1 2 1 1 2 3 2 3 2
result:
ok good plan
Test #5:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
3 8 12
output:
8 3 1 2 1 1 2 1 2 3 2 2 3 1 3 1 3
result:
ok good plan
Test #6:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
5 9 13
output:
10 2 1 3 2 1 2 2 1 2 1 3 1 1 3 2 3 1 3 2 3
result:
ok good plan
Test #7:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
4 15 26
output:
10 2 1 2 1 1 2 3 2 1 2 2 1 2 1 3 1 2 1 3 1
result:
ok good plan
Test #8:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
8 27 46
output:
16 2 1 2 1 3 2 1 2 3 2 1 2 3 1 3 1 3 1 3 1 2 3 2 3 2 3 2 3 2 3 1 3
result:
ok good plan
Test #9:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
27 35 43
output:
13 2 1 3 2 1 2 3 2 2 3 2 3 1 3 1 3 2 1 2 1 2 1 3 1 3 1
result:
ok good plan
Test #10:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
8 35 62
output:
12 3 1 3 1 2 1 1 2 1 2 3 2 3 2 1 3 1 3 1 3 2 3 2 3
result:
ok good plan
Test #11:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
66 95 98
output:
23 2 1 3 2 3 2 1 3 2 3 1 3 2 3 3 2 3 2 1 2 1 2 2 1 2 1 3 1 3 1 2 1 1 2 3 2 1 2 1 2 1 2 3 2 3 2
result:
ok good plan
Test #12:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
109 167 289
output:
25 2 1 1 2 1 2 2 1 3 1 2 1 1 2 1 2 1 2 1 2 3 2 1 3 1 3 2 3 2 3 1 3 3 1 3 1 2 1 3 1 2 1 3 1 3 1 3 1 2 1
result:
ok good plan
Test #13:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
269 380 398
output:
28 2 1 3 2 3 2 1 3 2 3 2 3 3 2 3 2 3 2 1 2 3 1 3 1 2 3 2 3 2 3 1 3 3 1 2 1 2 1 3 1 3 1 2 3 2 3 2 3 2 3 2 3 1 3 1 3
result:
ok good plan
Test #14:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
233 364 480
output:
22 2 1 1 2 1 2 2 1 3 1 3 1 1 3 2 3 1 3 2 3 3 2 3 2 1 2 1 2 3 1 3 1 3 1 2 1 2 1 2 1 2 1 2 1
result:
ok good plan
Test #15:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
1098 1376 1489
output:
48 2 1 3 2 1 2 3 2 2 3 2 3 2 3 2 3 1 3 2 1 3 1 2 1 2 1 1 2 3 2 3 2 3 2 1 2 3 2 1 2 2 1 3 1 3 1 2 1 2 1 3 1 3 1 3 1 2 1 1 2 3 2 1 2 1 2 3 2 1 2 3 2 3 2 3 2 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 #16:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
10035 10338 10444
output:
81 2 1 1 2 3 2 1 2 1 2 1 2 3 2 1 3 1 3 1 3 1 3 2 3 2 3 1 3 2 1 3 1 3 1 3 1 3 1 3 1 2 1 2 1 1 2 1 2 1 2 3 2 1 2 1 2 3 2 3 2 3 2 1 3 2 3 1 3 2 3 1 3 2 3 1 3 1 3 1 3 2 3 1 3 3 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 3 2 3 2 3 2 3 2 1 2 3 2 1 2 1 2 1 2 1 2 3 2 1 2 3 2 2 3 2 3 2 3 2 3 2 3 1 3 1 3 2...
result:
ok good plan
Test #17:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
100010 100200 100227
output:
75 2 1 3 2 3 2 3 2 3 2 1 2 1 2 1 2 1 2 1 2 3 2 2 3 1 3 2 3 2 3 2 3 2 3 1 3 2 3 2 3 2 3 1 3 3 1 2 1 3 1 3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 3 2 3 2 1 2 1 2 1 2 3 2 3 2 1 2 1 2 2 1 2 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 3 1 3 1 2 1 1 2 3 2 3 2 1 2 1 2 1 2 1 2 3 2 1 2 1 2 3 2 3 2 3 2 1 2 3 2
result:
ok good plan
Test #18:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
1000000 1000235 1000288
output:
75 2 1 1 2 1 2 1 2 1 2 1 2 3 2 1 2 3 2 1 2 1 2 1 2 1 2 3 2 2 3 2 3 2 3 2 3 1 3 2 3 1 3 1 3 2 3 2 3 2 3 2 3 2 3 1 3 2 1 2 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2 1 2 1 2 1 3 1 2 1 1 2 1 2 3 2 1 2 1 2 3 2 3 2 1 2 1 2 1 2 3 2 3 2 3 2 3 2 1 2 2 1 2 1 2 1 3 1 3 1 2 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
result:
ok good plan
Test #19:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
10000011 10000314 10000358
output:
200 2 1 1 2 1 2 3 2 3 2 1 2 3 2 3 2 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 2 1 3 2 3 2 3 2 3 2 3 1 3 1 3 2 3 1 3 1 3 1 3 1 3 2 3 2 3 2 3 2 3 1 3 2 1 2 1 2 1 3 1 2 1 2 1 3 1 2 1 2 1 3 1 2 1 3 1 2 1 3 1 2 1 3 1 3 1 2 1 3 2 3 2 3 2 1 2 1 2 1 2 1 2 1 2 3 2 3 2 3 2 1 2 3 2 3 2 3 2 3 2 1 2 1 2 3 2 2 3 2 3 1 3 ...
result:
ok good plan
Test #20:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
100000057 100000244 100000402
output:
119 2 1 3 2 1 2 1 2 3 2 1 2 3 2 3 2 3 2 1 2 1 2 1 2 3 2 1 2 3 2 1 2 1 2 1 2 1 2 1 2 3 2 2 3 1 3 1 3 2 3 2 3 1 3 1 3 1 3 2 3 2 3 2 3 2 3 1 3 1 3 2 3 1 3 2 3 2 3 2 3 2 3 1 3 2 1 3 1 3 1 2 1 3 1 3 1 2 1 3 1 3 1 2 1 2 1 3 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 3 2 1 2 1 2 3 2 1 2 3 2 3 2 ...
result:
ok good plan
Test #21:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
1 1000000 1000000000
output:
20 3 1 3 1 3 1 3 1 3 1 3 1 2 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 3 1 2 1 2 1 2 1 2 1
result:
ok good plan
Test #22:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
1024 65536 536870912
output:
7 3 1 3 1 3 1 3 1 3 1 3 1 2 1
result:
ok good plan
Test #23:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
6 268435456 536870912
output:
53 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: 3596kb
input:
7 16777217 536870909
output:
46 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 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: 3500kb
input:
24223 44594 72242
output:
50 2 1 3 2 1 2 2 1 3 1 3 1 2 3 1 3 2 3 1 3 3 1 3 1 3 1 2 1 1 2 1 2 3 2 3 2 2 3 1 3 2 3 1 3 2 3 1 2 1 2 3 2 3 2 1 2 1 2 1 2 1 2 3 1 3 1 3 1 3 1 3 1 3 1 2 1 3 1 2 1 3 2 3 2 3 2 1 2 1 2 3 2 1 2 1 2 1 2 1 2
result:
ok good plan
Test #26:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
123441 146831 150393
output:
113 2 1 1 2 3 2 3 2 1 3 2 3 1 3 1 3 2 3 1 2 1 2 1 2 1 2 2 1 2 1 3 1 2 1 2 1 2 1 3 1 3 1 2 1 1 2 1 2 3 2 3 2 3 2 3 2 1 2 3 2 3 2 1 2 3 2 1 2 3 1 2 1 2 1 2 1 2 1 3 1 2 1 2 1 2 1 3 1 2 1 3 1 2 1 2 1 3 1 2 3 2 3 1 3 2 3 1 3 2 3 1 3 1 3 1 3 2 3 2 3 1 3 1 3 1 3 2 3 3 2 3 2 3 2 3 2 1 2 1 2 1 2 3 2 1 2 3 2 ...
result:
ok good plan
Test #27:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
1017604 1044219 1047264
output:
124 2 1 3 2 3 2 3 2 1 2 1 2 3 2 2 3 1 3 1 3 2 3 1 3 2 3 2 3 1 3 3 1 2 1 2 1 2 1 2 1 3 1 3 1 2 1 3 2 3 2 3 2 1 2 3 2 3 2 1 2 1 2 1 2 2 1 3 1 2 1 3 1 2 1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 2 1 1 2 1 2 3 2 1 2 1 2 1 2 3 2 3 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 1 3 2 3 2 3 2 3 2 3 1 3 1 3 2 3 ...
result:
ok good plan
Test #28:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
10023437 10049857 10053253
output:
124 2 1 1 2 1 2 3 2 3 2 3 2 3 2 3 2 1 2 3 2 1 3 2 3 2 3 2 3 2 3 1 3 2 3 2 3 2 3 2 3 1 2 3 2 1 2 3 2 1 2 3 2 1 2 1 2 3 2 1 2 3 2 1 3 1 3 2 3 2 3 2 3 1 3 2 3 1 3 2 3 2 3 1 3 2 1 2 1 3 1 2 1 3 1 3 1 3 1 3 1 2 1 2 1 2 1 3 1 2 3 1 3 2 3 2 3 1 3 2 3 2 3 2 3 2 3 2 3 1 2 3 2 1 2 1 2 1 2 1 2 1 2 3 2 3 2 1 2 ...
result:
ok good plan
Test #29:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
100010076 100034479 100039408
output:
184 2 1 3 2 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 2 1 3 2 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 2 3 2 3 2 3 2 3 1 3 2 1 2 1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 2 1 3 1 2 1 3 1 3 1 2 1 3 2 1 2 3 2 3 2 1 2 3 2 3 2 1 2 1 2 1 2 1 2 3 2 1 2 1 2 3 2 1 3 2 3 1 3 1 3 1 3 2 3 2 3 2 3 2 3 1 3 2 3 2 3 1 3 1 3 1 3 2 1 ...
result:
ok good plan
Test #30:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
100021199 100049225 100065369
output:
127 2 1 1 2 3 2 1 2 1 2 3 2 3 2 3 2 3 2 3 2 1 2 3 2 3 2 2 3 2 3 1 3 2 3 2 3 2 3 1 3 2 3 2 3 2 3 1 3 1 3 1 3 2 3 1 2 3 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 3 2 3 2 1 2 3 2 1 2 2 1 2 1 2 1 3 1 3 1 2 1 2 1 3 1 3 1 3 1 2 1 3 1 3 1 3 1 2 1 1 2 3 2 3 2 1 2 1 2 1 2 3 2 3 2 1 2 3 2 3 2 3 2 1 2 1 2 3 2 1 3 2 3 2 3 ...
result:
ok good plan