QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#385124 | #2160. Cardiology | bulijiojiodibuliduo# | AC ✓ | 952ms | 4140kb | C++17 | 1.5kb | 2024-04-10 15:47:58 | 2024-04-10 15:48:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
int r,c;
int main() {
scanf("%d%d",&r,&c);
int dis=-1;
PII pos(-1,-1);
int pp=-1;
auto test=[&](int x,int y,PII pos,int pp) {
int step=0;
ll cc=(ll)pp*r;
while (mp(x,y)!=pos&&step<=100) {
++step;
ll val=cc+x;
x=val/c,y=val%c;
}
return step;
};
rep(p,0,c) {
function<void(int,int)> upd=[&](int xx,int yy) {
if (xx<0||xx>=r||yy<0||yy>=c) return;
if (test(0,0,mp(xx,yy),p)>=100||test(r-1,c-1,mp(xx,yy),p)>=100)
return;
int d=min(xx,r-xx-1)+min(yy,c-yy-1);
if (d>dis) {
dis=d;
pos=mp(xx,yy);
pp=p;
}
};
ll v=(ll)p*r;
upd(v/(c-1),v%(c-1));
if (v%(c-1)==0) upd(v/(c-1)-1,c-1);
}
//printf("? %d %d %d\n",pos.fi,pos.se,pp);
int ret=max(test(0,0,pos,pp),test(r-1,c-1,pos,pp));
printf("%d %d %d %d\n",pp+1,pos.fi+1,pos.se+1,ret);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 22ms
memory: 3776kb
input:
6666 966364
output:
473832 3269 483163 2
result:
ok single line: '473832 3269 483163 2'
Test #2:
score: 0
Accepted
time: 21ms
memory: 3832kb
input:
36 906986
output:
12598 1 453493 2
result:
ok single line: '12598 1 453493 2'
Test #3:
score: 0
Accepted
time: 9ms
memory: 3892kb
input:
704877 297616
output:
148803 352426 140980 3
result:
ok single line: '148803 352426 140980 3'
Test #4:
score: 0
Accepted
time: 24ms
memory: 3816kb
input:
1000000 1000000
output:
500000 500000 500000 2
result:
ok single line: '500000 500000 500000 2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 2
output:
1 1 1 2
result:
ok single line: '1 1 1 2'
Test #6:
score: 0
Accepted
time: 0ms
memory: 4140kb
input:
1000000 2
output:
1 1 1 21
result:
ok single line: '1 1 1 21'
Test #7:
score: 0
Accepted
time: 22ms
memory: 4084kb
input:
2 1000000
output:
250001 1 500001 2
result:
ok single line: '250001 1 500001 2'
Test #8:
score: 0
Accepted
time: 15ms
memory: 3820kb
input:
985391 511611
output:
255806 492696 255806 3
result:
ok single line: '255806 492696 255806 3'
Test #9:
score: 0
Accepted
time: 18ms
memory: 3888kb
input:
435766 614914
output:
304739 215957 307481 2
result:
ok single line: '304739 215957 307481 2'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
818196 58
output:
29 401921 49 5
result:
ok single line: '29 401921 49 5'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
401765 19
output:
10 200883 10 6
result:
ok single line: '10 200883 10 6'
Test #12:
score: 0
Accepted
time: 21ms
memory: 3824kb
input:
95 912669
output:
456335 48 456335 2
result:
ok single line: '456335 48 456335 2'
Test #13:
score: 0
Accepted
time: 10ms
memory: 4124kb
input:
81 429950
output:
2655 1 214975 2
result:
ok single line: '2655 1 214975 2'
Test #14:
score: 0
Accepted
time: 25ms
memory: 4116kb
input:
999956 999959
output:
249991 249990 499979 3
result:
ok single line: '249991 249990 499979 3'
Test #15:
score: 0
Accepted
time: 25ms
memory: 3824kb
input:
999935 999946
output:
449976 449971 499976 3
result:
ok single line: '449976 449971 499976 3'
Test #16:
score: 0
Accepted
time: 952ms
memory: 3828kb
input:
999951 999952
output:
1 1 1 2
result:
ok single line: '1 1 1 2'
Test #17:
score: 0
Accepted
time: 6ms
memory: 4116kb
input:
106352 224337
output:
112111 53149 112993 2
result:
ok single line: '112111 53149 112993 2'
Test #18:
score: 0
Accepted
time: 21ms
memory: 3908kb
input:
651870 786333
output:
392936 325744 393775 2
result:
ok single line: '392936 325744 393775 2'
Test #19:
score: 0
Accepted
time: 27ms
memory: 3860kb
input:
838522 972888
output:
486249 419093 486853 2
result:
ok single line: '486249 419093 486853 2'