QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#167224 | #2731. Cartesian Conquest | lmeowdn | 5 | 30ms | 42904kb | C++14 | 2.0kb | 2023-09-07 12:57:15 | 2023-09-07 12:57:16 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
pii operator + (const pii a,const pii b) {
return pii(min(a.fi,b.fi),max(a.se,b.se));
}
pii operator + (const pii a,const int b) {
return pii(a.fi+b,a.se+b);
}
pii dfs(int n,int m) {
if(n>m) swap(n,m);
if(n==0) return pii(0,0);
if(m>=4*n) {
if(n%2==1) return dfs(n,m-2*n)+1;
else {
pii p=dfs(n,m-2*n);
p.fi++, p.se+=4;
return p;
}
} else if(m>=2*n) {
pii p=dfs(n,m-n*2)+1;
if(n%2==0) p=p+(dfs(n,m-n/2)+1);
return p;
} else {
pii p(n+m,0);
if(n%2==0) p=p+(dfs(n,m-n/2)+1);
if(m%2==0) p=p+(dfs(m,n-m/2)+1);
return p;
}
}
signed main() {
int n=read(), m=read();
auto [x,y]=dfs(n,m);
printf("%lld %lld\n",x,y);
return 0;
}
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 2ms
memory: 3992kb
input:
2 1
output:
1 1
result:
ok single line: '1 1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4080kb
input:
2 4
output:
1 4
result:
ok single line: '1 4'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
5 4
output:
4 4
result:
ok single line: '4 4'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
4 6
output:
3 6
result:
ok single line: '3 6'
Test #5:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
1000 2
output:
250 1000
result:
ok single line: '250 1000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
1 1000
output:
500 500
result:
ok single line: '500 500'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
1000 1000
output:
2 8
result:
ok single line: '2 8'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
872 976
output:
11 133
result:
ok single line: '11 133'
Test #9:
score: 0
Accepted
time: 1ms
memory: 4012kb
input:
768 992
output:
8 124
result:
ok single line: '8 124'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
960 896
output:
6 85
result:
ok single line: '6 85'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
832 992
output:
6 182
result:
ok single line: '6 182'
Test #12:
score: 0
Accepted
time: 0ms
memory: 4020kb
input:
26 7
output:
8 8
result:
ok single line: '8 8'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
38 71
output:
7 30
result:
ok single line: '7 30'
Test #14:
score: 0
Accepted
time: 1ms
memory: 4084kb
input:
52 22
output:
5 17
result:
ok single line: '5 17'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
18 74
output:
6 26
result:
ok single line: '6 26'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
63 88
output:
12 12
result:
ok single line: '12 12'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3832kb
input:
378 251
output:
11 43
result:
ok single line: '11 43'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3732kb
input:
981 122
output:
12 52
result:
ok single line: '12 52'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
410 478
output:
10 82
result:
ok single line: '10 82'
Subtask #2:
score: 0
Time Limit Exceeded
Test #20:
score: 8
Accepted
time: 1ms
memory: 4100kb
input:
2 1001
output:
251 1001
result:
ok single line: '251 1001'
Test #21:
score: 0
Accepted
time: 10ms
memory: 42844kb
input:
1 1000000
output:
500000 500000
result:
ok single line: '500000 500000'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
1000000 1000000
output:
2 25
result:
ok single line: '2 25'
Test #23:
score: 0
Accepted
time: 30ms
memory: 3760kb
input:
80400 64364
output:
18 622
result:
ok single line: '18 622'
Test #24:
score: 0
Accepted
time: 2ms
memory: 3836kb
input:
5290 4513
output:
15 633
result:
ok single line: '15 633'
Test #25:
score: 0
Accepted
time: 1ms
memory: 3732kb
input:
663518 314601
output:
82 148
result:
ok single line: '82 148'
Test #26:
score: 0
Accepted
time: 7ms
memory: 21576kb
input:
913836 913838
output:
34 913838
result:
ok single line: '34 913838'
Test #27:
score: 0
Accepted
time: 20ms
memory: 42904kb
input:
995579 995578
output:
506 497793
result:
ok single line: '506 497793'
Test #28:
score: 0
Accepted
time: 18ms
memory: 42696kb
input:
997467 997466
output:
36 498737
result:
ok single line: '36 498737'
Test #29:
score: 0
Accepted
time: 24ms
memory: 11608kb
input:
769244 961556
output:
33 384627
result:
ok single line: '33 384627'
Test #30:
score: -8
Time Limit Exceeded
input:
884224 753344
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #45:
score: 0
Runtime Error
input:
100000000 2