QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#106523 | #3061. Donut Drone | Determinant | TL | 3989ms | 50564kb | C++14 | 1.6kb | 2023-05-17 23:36:42 | 2023-05-17 23:37:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;const int N=2007,M=1;
int n,m,q,a[N][N],b[N][N],c[N][N],d[N],vis[N],bl[N],fr[N],ed[N],nx,ny;
char ch[9];
void calc(int x,int y){
int x0=(x+n-2)%n+1,x1=x,x2=x%n+1,y0=y%m+1;
if(a[x0][y0]>a[x1][y0])b[x][y]=(a[x0][y0]>a[x2][y0]?x0:x2);
else b[x][y]=(a[x1][y0]>a[x2][y0]?x1:x2);
}
void upd_d(){
for(int i=1;i<=n;++i){
int p=i;for(int j=0;j<=bl[m];++j)p=c[j][p];d[i]=p;
}
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)scanf("%d",&a[i][j]);
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)calc(i,j);
for(int i=1;i<=m;++i)bl[i]=i/M;nx=ny=1;
for(int i=0;i<=bl[m];++i)fr[i]=max(i*M,1),ed[i]=min(m,i*M+M-1);
for(int i=0;i<=bl[m];++i){
for(int j=1;j<=n;++j){
int p=j;for(int k=fr[i];k<=ed[i];++k)p=b[p][k];
c[i][j]=p;
}
}
upd_d();
scanf("%d",&q);while(q--){
int x,y,z;scanf("%s%d",ch,&x);
if(ch[0]=='m'){
while(x&&ny!=m+1)nx=b[nx][ny],ny++,x--;if(ny>m)ny-=m;
if(!x){printf("%d %d\n",nx,ny);continue;}
int w=x/m,qt=0;for(int i=1;i<=n;++i)vis[i]=-1;vis[nx]=0;
while(qt<w){
nx=d[nx];++qt;
if(vis[nx]>=0){w=(w-qt)%(qt-vis[nx]);qt=0;break;}
vis[nx]=++qt;
}
while(qt<w)++qt,nx=d[nx];
for(int i=1;i<=x%m;++i)nx=b[nx][ny],ny++;
printf("%d %d\n",nx,ny);
}
else{
scanf("%d%d",&y,&z);a[x][y]=z;
int x0=(x+n-2)%n+1,x1=x,x2=x%n+1,y0=(y+m-2)%m+1;
calc(x0,y0);calc(x1,y0);calc(x2,y0);y0=bl[y0];
for(int i=1;i<=n;++i){
int p=i;for(int j=fr[y0];j<=ed[y0];++j)p=b[p][j];
c[y0][i]=p;
}
upd_d();
}
}
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3636kb
input:
4 4 1 2 9 3 3 5 4 8 4 3 2 7 5 8 1 6 4 move 1 move 1 change 1 4 100 move 1
output:
4 2 1 3 1 4
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 3624kb
input:
3 4 10 20 30 40 50 60 70 80 90 93 95 99 3 move 4 change 2 1 100 move 4
output:
3 1 2 1
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 6ms
memory: 3876kb
input:
20 30 8 1 7 4 3 1 2 1 5 5 2 7 6 4 7 1 2 9 1 9 9 9 9 6 4 9 1 6 3 10 7 3 5 6 5 3 5 3 1 9 8 8 7 7 6 7 5 10 9 6 5 3 8 2 7 10 6 8 4 3 6 4 3 1 7 7 6 7 2 7 3 6 8 6 3 2 7 8 10 8 6 5 6 10 2 6 5 10 10 9 2 5 10 9 4 9 3 6 10 8 1 7 3 3 7 3 3 6 7 5 1 1 10 6 8 5 4 2 1 8 5 1 2 8 3 4 2 4 4 9 6 3 1 5 9 1 9 3 8 3 7 10...
output:
19 10 18 19 3 24 3 30 3 2 4 3 3 8 7 14 3 21 2 27 3 7 3 8 6 16 5 17 3 24 2 27 3 29 3 8 7 12 6 16 3 22 3 2 7 12 3 19 1 22 4 25 4 3 3 5 7 12 3 20 1 22 2 24 3 2 6 11 3 20 2 24 4 4 3 5 5 10 6 11 4 18 2 21 3 29 3 2 3 5 4 9 6 16 2 25 1 26 2 1 4 6 7 15 2 24 3 2 7 12 3 19 3 28 5 4 9 11 9 12 11 17 10 19 12 21...
result:
ok 1945 lines
Test #4:
score: 0
Accepted
time: 13ms
memory: 4232kb
input:
50 50 126812431 909179109 607682292 96000160 425314080 189788877 721251789 103560861 114082307 888028612 277663589 257100764 842807257 327052508 652365304 770138116 384723035 680037089 675501229 509497026 174936063 991259231 761329528 658883078 806406343 741076652 973854314 192609094 398064987 65322...
output:
46 21 46 21 1 49 47 20 46 37 1 42 45 35 50 50 2 17 1 43 2 38 2 47 50 50 2 38 50 50 2 26 2 17 2 34 2 21 4 9 3 6 1 2 1 30 2 40 2 21 2 35 2 17 2 31 2 32 4 9 2 42 3 12 4 8 2 31 1 3 2 15 1 48 1 20 1 30 2 17 49 49 2 14 2 4 1 30 1 29 2 40 2 24 1 27 1 36 1 27 49 47 3 6 2 32 3 41 49 48 2 34 3 41 47 22 49 28 ...
result:
ok 502 lines
Test #5:
score: 0
Accepted
time: 357ms
memory: 5388kb
input:
100 191 178 164 436 292 160 15 447 40 415 308 107 456 61 483 370 222 49 178 96 272 359 232 285 356 320 316 56 450 34 30 300 15 53 269 210 271 443 169 387 273 181 175 38 177 167 447 376 252 434 97 334 389 349 216 293 265 227 273 171 351 68 481 430 249 482 117 206 429 359 61 431 207 163 336 329 490 20...
output:
94 140 94 149 98 91 98 19 97 121 94 169 3 51 98 97 1 37 1 37 3 61 97 10 98 13 93 179 95 146 97 8 97 130 96 6 95 158 98 122 94 181 94 140 97 117 94 176 96 133 100 38 99 29 1 68 3 59 3 46 97 124 93 155 95 139 94 143 10 10 13 63 7 184 8 164 13 62 12 57 15 41 10 10 12 84 8 2 11 89 11 119 12 92 7 166 9 7...
result:
ok 516 lines
Test #6:
score: 0
Accepted
time: 3989ms
memory: 50564kb
input:
1999 1971 274359794 615065638 314433231 715787778 486221282 877103113 462895814 602525302 496926569 16482389 7389157 94419868 841896951 423947821 735538885 670514061 398818169 503874450 256795479 71430930 757204344 924882965 721532878 511539013 917383058 160383266 270331386 296482213 104942177 30363...
output:
19 867 17 863 19 472 21 898 27 1104 29 1490 35 1470 28 64 21 24 34 1360 32 1384 10 756 17 915 30 1504 32 1398 22 16 35 1141 15 553 21 378 34 1168 18 455 16 515 33 1299 28 1556 34 1599 35 1443 9 685 32 1572 31 1205 22 386 26 1959 31 1200 20 817 30 1407 17 877 11 737 24 121 30 1546 25 156 10 997 18 44...
result:
ok 4951 lines
Test #7:
score: -100
Time Limit Exceeded
input:
1999 1972 908570368 576114585 871607413 105528864 717151909 868091308 442016015 96884299 951725816 178293034 660937316 882194661 290229206 116518447 685144293 777163613 825739358 379460279 316897433 343444500 220852674 464535570 629533274 19187139 768795424 839233681 621997087 563642576 573864427 21...