QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#283536#7740. Puzzle: Question Markbachbeo2007AC ✓225ms35092kbC++234.2kb2023-12-14 19:01:092023-12-14 19:01:09

Judging History

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

  • [2023-12-14 19:01:09]
  • 评测
  • 测评结果:AC
  • 用时:225ms
  • 内存:35092kb
  • [2023-12-14 19:01:09]
  • 提交

answer

// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- insert(x),erase(x)
- find_by_order(k): return iterator to the k-th smallest element
- order_of_key(x): the number of elements that are strictly smaller
*/
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define int long long
#define ld long double
#define pii pair<int,int>
#define piii pair<int,pii>
#define mpp make_pair
#define fi first
#define se second
const int inf=1e18;
const int mod=998244353;
const int maxn=2005;
const int bl=650;
const int maxs=655;
const int maxm=200005;
const int maxq=1000005;
const int maxl=25;
const int maxa=1000000;
const int root=3;
int power(int a,int n){
    int res=1;
    while(n){
        if(n&1) res=res*a%mod;
        a=a*a%mod;n>>=1;
    }
    return res;
}
const int iroot=power(3,mod-2);
const int base=131;

int res[maxn][maxn],cnt;

void f22(int x,int y,int cc){
    for(int i=0;i<=1;i++) for(int j=0;j<=1;j++) res[x+i][y+j]=cc;
}

void f24(int x,int y){
    for(int i=0;i<2;i++) for(int j=0;j<4;j++) res[x+i][y+j]=cnt+!!((j&(i+1)));
    cnt+=2;
}
void f42(int x,int y){
    for(int i=0;i<4;i++) for(int j=0;j<2;j++) res[x+i][y+j]=cnt+!!((i&(j+1)));
    cnt+=2;
}
void ft33(int x,int y){
    f22(x+1,y,cnt);
    f22(x,y+1,cnt+1);
    res[x+1][y+2]=cnt;
    res[x+2][y+2]=cnt+1;
    cnt+=2;
}
void fd33(int x,int y){
    f22(x+1,y+1,cnt+1);
    f22(x,y,cnt);
    res[x][y+2]=cnt;
    res[x][y+1]=cnt+1;
    cnt+=2;
}
void fl222(int x,int y){
    f22(x,y,cnt);
    f22(x+2,y+1,cnt+1);
    res[x+2][y+1]=cnt;
    res[x+1][y+1]=cnt+1;
    cnt+=2;
}
void fr222(int x,int y){
    f22(x,y+2,cnt);
    f22(x+1,y,cnt+1);
    res[x+1][y+1]=cnt;
    res[x+1][y+2]=cnt+1;
    cnt+=2;
}
void fL222(int x,int y){
    f22(x,y,cnt);
    f22(x+1,y+2,cnt+1);
    res[x+1][y+1]=cnt+1;
    res[x+1][y+2]=cnt;
    cnt+=2;
}
void rev33(int x,int y){
    for(int i=0;i<=2;i++) swap(res[x+i][y],res[x+i][y+2]);
}

void build(int x,int y,int n){
    if(n<=2) return;
    if(n==9){
        f24(x+1,y+1);
        fd33(x+1,y+5);
        f42(x+1,y+8);
        fL222(x+3,y+4);
        fd33(x+3,y+1);
        rev33(x+3,y+1);
        ft33(x+5,y+7);
        f24(x+8,y+6);
        f42(x+6,y+1);
        ft33(x+7,y+3);
        rev33(x+7,y+3);
        fL222(x+5,y+3);
    }
    else if(n==5){
        f24(x+1,y+1);
        ft33(x+3,y+3);
        res[x+3][y+1]=res[x+3][y+3]=res[x+4][y+1]=res[x+4][y+2]=cnt++;
    }
    else if(n%2==0){
        for(int i=1;i<=n;i+=2){
            f24(x+i,y+n-3);
            if(i<n-3) f42(x+n-3,y+i);
        }
        build(x,y,n-4);
    }
    else if(n%4==1){
        for(int i=1;i<=n-5;i+=4){
            f24(x+1,y+i);
            f24(x+n-1,y+i);
        }
        fl222(x+1,y+n-4);
        fd33(x+1,y+n-2);
        ft33(x+n-2,y+n-4);
        f42(x+n-3,y+n-1);
        for(int i=4;i<=n-4;i+=2) fr222(x+i,y+n-3);
        build(x+2,y,n-4);
    }
    else if(n%4==3){
        ft33(x+n-2,y+n-2);
        for(int i=1;i<=n-3;i+=4){
            f42(x+i,y+n-1);
            f24(x+n-1,y+i);
        }
        build(x,y,n-2);
    }
}

void solve(){
    int n;cin >> n;cnt=1;
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) res[i][j]=0;
    build(0,0,n);
    cout << cnt-1 << '\n';
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) cout << res[i][j] << " \n"[j==n];
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int test=1;cin >> test;
    while(test--) solve();
}


这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

2
3
4

output:

2
0 2 2
1 2 1
1 1 2
4
1 2 1 2
1 1 2 2
3 4 3 4
3 3 4 4

result:

ok Correct. (2 test cases)

Test #2:

score: 0
Accepted
time: 191ms
memory: 7952kb

input:

246
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...

output:

0
0
0
0 0
0 0
2
0 2 2
1 2 1
1 1 2
4
1 2 1 2
1 1 2 2
3 4 3 4
3 3 4 4
5
1 2 1 2 0
1 1 2 2 0
5 0 5 4 4
5 5 3 4 3
0 0 3 3 4
8
0 0 1 2 1 2
0 0 1 1 2 2
3 3 5 6 5 6
4 3 5 5 6 6
3 4 7 8 7 8
4 4 7 7 8 8
11
7 8 7 8 0 3 3
7 7 8 8 0 4 3
11 0 11 10 10 3 4
11 11 9 10 9 4 4
0 0 9 9 10 2 2
5 6 5 6 1 2 1
5 5 6 6 1 1...

result:

ok Correct. (246 test cases)

Test #3:

score: 0
Accepted
time: 183ms
memory: 8116kb

input:

64
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310

output:

15252
247 248 247 248 251 252 251 252 255 256 255 256 259 260 259 260 263 264 263 264 267 268 267 268 271 272 271 272 275 276 275 276 279 280 279 280 283 284 283 284 287 288 287 288 291 292 291 292 295 296 295 296 299 300 299 300 303 304 303 304 307 308 307 308 311 312 311 312 315 316 315 316 319 32...

result:

ok Correct. (64 test cases)

Test #4:

score: 0
Accepted
time: 191ms
memory: 10328kb

input:

45
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355

output:

24180
311 312 311 312 315 316 315 316 319 320 319 320 323 324 323 324 327 328 327 328 331 332 331 332 335 336 335 336 339 340 339 340 343 344 343 344 347 348 347 348 351 352 351 352 355 356 355 356 359 360 359 360 363 364 363 364 367 368 367 368 371 372 371 372 375 376 375 376 379 380 379 380 383 38...

result:

ok Correct. (45 test cases)

Test #5:

score: 0
Accepted
time: 201ms
memory: 9900kb

input:

35
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390

output:

31684
31681 31682 31681 31682 31669 31670 31669 31670 31649 31650 31649 31650 31621 31622 31621 31622 31585 31586 31585 31586 31541 31542 31541 31542 31489 31490 31489 31490 31429 31430 31429 31430 31361 31362 31361 31362 31285 31286 31285 31286 31201 31202 31201 31202 31109 31110 31109 31110 31009 ...

result:

ok Correct. (35 test cases)

Test #6:

score: 0
Accepted
time: 182ms
memory: 10364kb

input:

30
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420

output:

38220
391 392 391 392 395 396 395 396 399 400 399 400 403 404 403 404 407 408 407 408 411 412 411 412 415 416 415 416 419 420 419 420 423 424 423 424 427 428 427 428 431 432 431 432 435 436 435 436 439 440 439 440 443 444 443 444 447 448 447 448 451 452 451 452 455 456 455 456 459 460 459 460 463 46...

result:

ok Correct. (30 test cases)

Test #7:

score: 0
Accepted
time: 212ms
memory: 35012kb

input:

2
2000
1000

output:

1000000
999997 999998 999997 999998 999985 999986 999985 999986 999965 999966 999965 999966 999937 999938 999937 999938 999901 999902 999901 999902 999857 999858 999857 999858 999805 999806 999805 999806 999745 999746 999745 999746 999677 999678 999677 999678 999601 999602 999601 999602 999517 99951...

result:

ok Correct. (2 test cases)

Test #8:

score: 0
Accepted
time: 215ms
memory: 35088kb

input:

2
1999
999

output:

999000
1999 2000 1999 2000 2003 2004 2003 2004 2007 2008 2007 2008 2011 2012 2011 2012 2015 2016 2015 2016 2019 2020 2019 2020 2023 2024 2023 2024 2027 2028 2027 2028 2031 2032 2031 2032 2035 2036 2035 2036 2039 2040 2039 2040 2043 2044 2043 2044 2047 2048 2047 2048 2051 2052 2051 2052 2055 2056 205...

result:

ok Correct. (2 test cases)

Test #9:

score: 0
Accepted
time: 218ms
memory: 34952kb

input:

2
1998
998

output:

998000
0 0 997993 997994 997993 997994 997977 997978 997977 997978 997953 997954 997953 997954 997921 997922 997921 997922 997881 997882 997881 997882 997833 997834 997833 997834 997777 997778 997777 997778 997713 997714 997713 997714 997641 997642 997641 997642 997561 997562 997561 997562 997473 99...

result:

ok Correct. (2 test cases)

Test #10:

score: 0
Accepted
time: 203ms
memory: 35092kb

input:

2
1997
997

output:

997002
1 2 1 2 5 6 5 6 9 10 9 10 13 14 13 14 17 18 17 18 21 22 21 22 25 26 25 26 29 30 29 30 33 34 33 34 37 38 37 38 41 42 41 42 45 46 45 46 49 50 49 50 53 54 53 54 57 58 57 58 61 62 61 62 65 66 65 66 69 70 69 70 73 74 73 74 77 78 77 78 81 82 81 82 85 86 85 86 89 90 89 90 93 94 93 94 97 98 97 98 101...

result:

ok Correct. (2 test cases)

Test #11:

score: 0
Accepted
time: 219ms
memory: 34884kb

input:

2
1996
996

output:

996004
996001 996002 996001 996002 995989 995990 995989 995990 995969 995970 995969 995970 995941 995942 995941 995942 995905 995906 995905 995906 995861 995862 995861 995862 995809 995810 995809 995810 995749 995750 995749 995750 995681 995682 995681 995682 995605 995606 995605 995606 995521 995522...

result:

ok Correct. (2 test cases)

Test #12:

score: 0
Accepted
time: 216ms
memory: 34956kb

input:

2
1995
995

output:

995006
1995 1996 1995 1996 1999 2000 1999 2000 2003 2004 2003 2004 2007 2008 2007 2008 2011 2012 2011 2012 2015 2016 2015 2016 2019 2020 2019 2020 2023 2024 2023 2024 2027 2028 2027 2028 2031 2032 2031 2032 2035 2036 2035 2036 2039 2040 2039 2040 2043 2044 2043 2044 2047 2048 2047 2048 2051 2052 205...

result:

ok Correct. (2 test cases)

Test #13:

score: 0
Accepted
time: 222ms
memory: 35052kb

input:

2
1994
994

output:

994008
0 0 994001 994002 994001 994002 993985 993986 993985 993986 993961 993962 993961 993962 993929 993930 993929 993930 993889 993890 993889 993890 993841 993842 993841 993842 993785 993786 993785 993786 993721 993722 993721 993722 993649 993650 993649 993650 993569 993570 993569 993570 993481 99...

result:

ok Correct. (2 test cases)

Test #14:

score: 0
Accepted
time: 222ms
memory: 34964kb

input:

2
1993
993

output:

993012
1 2 1 2 5 6 5 6 9 10 9 10 13 14 13 14 17 18 17 18 21 22 21 22 25 26 25 26 29 30 29 30 33 34 33 34 37 38 37 38 41 42 41 42 45 46 45 46 49 50 49 50 53 54 53 54 57 58 57 58 61 62 61 62 65 66 65 66 69 70 69 70 73 74 73 74 77 78 77 78 81 82 81 82 85 86 85 86 89 90 89 90 93 94 93 94 97 98 97 98 101...

result:

ok Correct. (2 test cases)

Test #15:

score: 0
Accepted
time: 216ms
memory: 34948kb

input:

2
1992
992

output:

992016
992013 992014 992013 992014 992001 992002 992001 992002 991981 991982 991981 991982 991953 991954 991953 991954 991917 991918 991917 991918 991873 991874 991873 991874 991821 991822 991821 991822 991761 991762 991761 991762 991693 991694 991693 991694 991617 991618 991617 991618 991533 991534...

result:

ok Correct. (2 test cases)

Test #16:

score: 0
Accepted
time: 225ms
memory: 34864kb

input:

2
1991
991

output:

991020
1991 1992 1991 1992 1995 1996 1995 1996 1999 2000 1999 2000 2003 2004 2003 2004 2007 2008 2007 2008 2011 2012 2011 2012 2015 2016 2015 2016 2019 2020 2019 2020 2023 2024 2023 2024 2027 2028 2027 2028 2031 2032 2031 2032 2035 2036 2035 2036 2039 2040 2039 2040 2043 2044 2043 2044 2047 2048 204...

result:

ok Correct. (2 test cases)

Extra Test:

score: 0
Extra Test Passed