QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#883868#9874. Matrix Constructiongaliyuu#AC ✓49ms7296kbC++23915b2025-02-05 19:31:582025-02-05 19:31:59

Judging History

This is the latest submission verdict.

  • [2025-02-05 19:31:59]
  • Judged
  • Verdict: AC
  • Time: 49ms
  • Memory: 7296kb
  • [2025-02-05 19:31:58]
  • Submitted

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 mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n'
#define SZ(x) ((ll)(x).size())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
mt19937 mrand(random_device{}());
int rnd(int x){return mrand()%x;}
const ll mod=998244353;

signed main() {
	int tc;
	scanf("%d",&tc);
	while (tc--) {
		int n,m;
		scanf("%d%d",&n,&m);
		puts("Yes");
		vector<vi> ans(n,vi(m));
		int id=n*m;
		rep(i,0,n+m) rep(j,0,n) {
			if (j>i) continue;
			if (i-j>=m) continue;
			ans[j][i-j]=id;
			id--;
		}
		rep(i,0,n) rep(j,0,m) {
			printf("%d ",ans[i][j]);
			if (j==m-1) puts("");
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
1 1
2 3

output:

Yes
1 
Yes
6 5 3 
4 2 1 

result:

ok All test cases passed. (2 test cases)

Test #2:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

361
4 9
11 12
16 14
3 7
17 13
1 19
12 3
15 19
11 3
8 18
13 10
8 13
9 18
14 11
7 13
6 16
12 13
1 6
11 15
18 19
5 6
17 19
2 3
17 11
16 19
6 14
5 9
7 2
5 11
15 16
3 15
7 11
16 2
19 15
5 19
2 17
13 12
3 5
19 14
6 3
18 2
16 4
6 8
10 9
17 4
5 16
17 9
16 11
6 9
16 5
3 19
18 9
13 9
12 19
6 13
17 15
13 7
12 ...

output:

Yes
36 35 33 30 26 22 18 14 10 
34 32 29 25 21 17 13 9 6 
31 28 24 20 16 12 8 5 3 
27 23 19 15 11 7 4 2 1 
Yes
132 131 129 126 122 117 111 104 96 87 77 66 
130 128 125 121 116 110 103 95 86 76 65 55 
127 124 120 115 109 102 94 85 75 64 54 45 
123 119 114 108 101 93 84 74 63 53 44 36 
118 113 107 100...

result:

ok All test cases passed. (361 test cases)

Test #3:

score: 0
Accepted
time: 3ms
memory: 3712kb

input:

264
23 1
25 8
21 15
23 21
9 20
23 9
7 22
19 24
8 23
12 21
10 23
23 7
21 19
9 25
9 21
25 21
25 18
16 24
22 24
16 23
1 21
22 6
14 24
11 22
15 25
17 20
25 16
23 3
16 21
21 21
3 20
20 21
7 20
3 23
3 21
21 5
22 19
9 23
20 23
6 22
24 10
22 8
20 2
12 20
20 25
24 22
23 15
22 13
25 22
24 3
13 20
3 24
15 23
2...

output:

Yes
23 
22 
21 
20 
19 
18 
17 
16 
15 
14 
13 
12 
11 
10 
9 
8 
7 
6 
5 
4 
3 
2 
1 
Yes
200 199 197 194 190 185 179 172 
198 196 193 189 184 178 171 164 
195 192 188 183 177 170 163 156 
191 187 182 176 169 162 155 148 
186 181 175 168 161 154 147 140 
180 174 167 160 153 146 139 132 
173 166 159...

result:

ok All test cases passed. (264 test cases)

Test #4:

score: 0
Accepted
time: 7ms
memory: 3712kb

input:

113
31 57
57 1
57 25
29 57
57 54
36 57
26 57
2 57
57 48
14 57
57 6
57 53
38 57
15 57
57 43
3 57
57 38
18 57
23 57
57 35
57 56
1 57
57 3
57 50
20 57
9 57
57 34
42 57
16 57
57 4
56 57
57 7
57 20
57 11
34 57
53 57
7 57
49 57
19 57
32 57
57 19
57 42
57 8
57 10
5 57
21 57
37 57
57 40
22 57
57 2
13 57
33 ...

output:

Yes
1767 1766 1764 1761 1757 1752 1746 1739 1731 1722 1712 1701 1689 1676 1662 1647 1631 1614 1596 1577 1557 1536 1514 1491 1467 1442 1416 1389 1361 1332 1302 1271 1240 1209 1178 1147 1116 1085 1054 1023 992 961 930 899 868 837 806 775 744 713 682 651 620 589 558 527 496 
1765 1763 1760 1756 1751 17...

result:

ok All test cases passed. (113 test cases)

Test #5:

score: 0
Accepted
time: 11ms
memory: 3968kb

input:

127
15 64
64 2
33 64
64 31
64 11
64 41
64 49
7 64
64 48
64 18
64 53
64 26
61 64
10 64
64 24
20 64
37 64
64 34
64 32
64 4
64 46
64 47
64 42
11 64
64 6
48 64
64 12
64 7
64 45
64 50
6 64
64 22
64 1
64 61
19 64
64 17
60 64
22 64
64 9
64 62
64 57
26 64
64 33
54 64
28 64
2 64
32 64
29 64
35 64
36 64
64 51...

output:

Yes
960 959 957 954 950 945 939 932 924 915 905 894 882 869 855 840 825 810 795 780 765 750 735 720 705 690 675 660 645 630 615 600 585 570 555 540 525 510 495 480 465 450 435 420 405 390 375 360 345 330 315 300 285 270 255 240 225 210 195 180 165 150 135 120 
958 956 953 949 944 938 931 923 914 904...

result:

ok All test cases passed. (127 test cases)

Test #6:

score: 0
Accepted
time: 43ms
memory: 3968kb

input:

195
44 98
98 92
98 20
50 98
98 31
98 75
98 68
37 98
5 98
41 98
34 98
98 46
98 91
98 90
98 22
98 11
9 98
98 58
98 52
39 98
18 98
19 98
98 87
98 10
66 98
11 98
36 98
85 98
88 98
84 98
98 21
64 98
98 37
20 98
98 6
98 67
1 98
47 98
38 98
29 98
98 86
23 98
56 98
98 59
45 98
63 98
60 98
98 79
93 98
24 98
...

output:

Yes
4312 4311 4309 4306 4302 4297 4291 4284 4276 4267 4257 4246 4234 4221 4207 4192 4176 4159 4141 4122 4102 4081 4059 4036 4012 3987 3961 3934 3906 3877 3847 3816 3784 3751 3717 3682 3646 3609 3571 3532 3492 3451 3409 3366 3322 3278 3234 3190 3146 3102 3058 3014 2970 2926 2882 2838 2794 2750 2706 2...

result:

ok All test cases passed. (195 test cases)

Test #7:

score: 0
Accepted
time: 44ms
memory: 3968kb

input:

199
100 35
100 85
77 100
100 36
75 100
100 42
100 28
89 100
54 100
97 100
22 100
100 50
86 100
100 22
63 100
17 100
32 100
58 100
74 100
9 100
100 29
100 97
100 77
20 100
100 62
56 100
100 41
1 100
100 8
50 100
60 100
15 100
100 74
100 75
100 67
100 49
81 100
100 63
100 89
100 7
70 100
100 93
100 59...

output:

Yes
3500 3499 3497 3494 3490 3485 3479 3472 3464 3455 3445 3434 3422 3409 3395 3380 3364 3347 3329 3310 3290 3269 3247 3224 3200 3175 3149 3122 3094 3065 3035 3004 2972 2939 2905 
3498 3496 3493 3489 3484 3478 3471 3463 3454 3444 3433 3421 3408 3394 3379 3363 3346 3328 3309 3289 3268 3246 3223 3199 ...

result:

ok All test cases passed. (199 test cases)

Test #8:

score: 0
Accepted
time: 11ms
memory: 3968kb

input:

100
93 4
25 100
87 56
44 54
9 7
20 84
4 56
7 85
77 81
78 35
22 53
5 54
88 70
91 8
96 11
16 74
26 22
11 80
50 84
69 94
41 42
15 29
63 28
36 3
9 78
56 8
24 86
46 76
87 39
41 73
10 18
42 65
59 4
96 56
29 46
97 77
66 23
63 99
90 39
44 35
47 66
59 69
62 39
39 76
21 69
79 40
48 58
23 26
38 76
37 10
6 64
6...

output:

Yes
372 371 369 366 
370 368 365 362 
367 364 361 358 
363 360 357 354 
359 356 353 350 
355 352 349 346 
351 348 345 342 
347 344 341 338 
343 340 337 334 
339 336 333 330 
335 332 329 326 
331 328 325 322 
327 324 321 318 
323 320 317 314 
319 316 313 310 
315 312 309 306 
311 308 305 302 
307 304...

result:

ok All test cases passed. (100 test cases)

Test #9:

score: 0
Accepted
time: 10ms
memory: 3968kb

input:

25
80 180
183 125
111 43
118 164
21 67
175 160
149 149
14 92
34 174
50 13
150 107
185 102
61 194
59 139
49 38
160 133
30 12
10 140
8 100
200 3
82 16
160 52
158 165
8 161
82 133

output:

Yes
14400 14399 14397 14394 14390 14385 14379 14372 14364 14355 14345 14334 14322 14309 14295 14280 14264 14247 14229 14210 14190 14169 14147 14124 14100 14075 14049 14022 13994 13965 13935 13904 13872 13839 13805 13770 13734 13697 13659 13620 13580 13539 13497 13454 13410 13365 13319 13272 13224 13...

result:

ok All test cases passed. (25 test cases)

Test #10:

score: 0
Accepted
time: 22ms
memory: 5376kb

input:

1
590 834

output:

Yes
492060 492059 492057 492054 492050 492045 492039 492032 492024 492015 492005 491994 491982 491969 491955 491940 491924 491907 491889 491870 491850 491829 491807 491784 491760 491735 491709 491682 491654 491625 491595 491564 491532 491499 491465 491430 491394 491357 491319 491280 491240 491199 49...

result:

ok All test cases passed. (1 test case)

Test #11:

score: 0
Accepted
time: 5ms
memory: 3964kb

input:

1
513 194

output:

Yes
99522 99521 99519 99516 99512 99507 99501 99494 99486 99477 99467 99456 99444 99431 99417 99402 99386 99369 99351 99332 99312 99291 99269 99246 99222 99197 99171 99144 99116 99087 99057 99026 98994 98961 98927 98892 98856 98819 98781 98742 98702 98661 98619 98576 98532 98487 98441 98394 98346 98...

result:

ok All test cases passed. (1 test case)

Test #12:

score: 0
Accepted
time: 15ms
memory: 4864kb

input:

1
923 363

output:

Yes
335049 335048 335046 335043 335039 335034 335028 335021 335013 335004 334994 334983 334971 334958 334944 334929 334913 334896 334878 334859 334839 334818 334796 334773 334749 334724 334698 334671 334643 334614 334584 334553 334521 334488 334454 334419 334383 334346 334308 334269 334229 334188 33...

result:

ok All test cases passed. (1 test case)

Test #13:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

1
141 19

output:

Yes
2679 2678 2676 2673 2669 2664 2658 2651 2643 2634 2624 2613 2601 2588 2574 2559 2543 2526 2508 
2677 2675 2672 2668 2663 2657 2650 2642 2633 2623 2612 2600 2587 2573 2558 2542 2525 2507 2489 
2674 2671 2667 2662 2656 2649 2641 2632 2622 2611 2599 2586 2572 2557 2541 2524 2506 2488 2470 
2670 266...

result:

ok All test cases passed. (1 test case)

Test #14:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

1
63 188

output:

Yes
11844 11843 11841 11838 11834 11829 11823 11816 11808 11799 11789 11778 11766 11753 11739 11724 11708 11691 11673 11654 11634 11613 11591 11568 11544 11519 11493 11466 11438 11409 11379 11348 11316 11283 11249 11214 11178 11141 11103 11064 11024 10983 10941 10898 10854 10809 10763 10716 10668 10...

result:

ok All test cases passed. (1 test case)

Test #15:

score: 0
Accepted
time: 24ms
memory: 5632kb

input:

1
840 630

output:

Yes
529200 529199 529197 529194 529190 529185 529179 529172 529164 529155 529145 529134 529122 529109 529095 529080 529064 529047 529029 529010 528990 528969 528947 528924 528900 528875 528849 528822 528794 528765 528735 528704 528672 528639 528605 528570 528534 528497 528459 528420 528380 528339 52...

result:

ok All test cases passed. (1 test case)

Test #16:

score: 0
Accepted
time: 33ms
memory: 6656kb

input:

1
840 945

output:

Yes
793800 793799 793797 793794 793790 793785 793779 793772 793764 793755 793745 793734 793722 793709 793695 793680 793664 793647 793629 793610 793590 793569 793547 793524 793500 793475 793449 793422 793394 793365 793335 793304 793272 793239 793205 793170 793134 793097 793059 793020 792980 792939 79...

result:

ok All test cases passed. (1 test case)

Test #17:

score: 0
Accepted
time: 44ms
memory: 7168kb

input:

1
997 991

output:

Yes
988027 988026 988024 988021 988017 988012 988006 987999 987991 987982 987972 987961 987949 987936 987922 987907 987891 987874 987856 987837 987817 987796 987774 987751 987727 987702 987676 987649 987621 987592 987562 987531 987499 987466 987432 987397 987361 987324 987286 987247 987207 987166 98...

result:

ok All test cases passed. (1 test case)

Test #18:

score: 0
Accepted
time: 44ms
memory: 7296kb

input:

1
971 997

output:

Yes
968087 968086 968084 968081 968077 968072 968066 968059 968051 968042 968032 968021 968009 967996 967982 967967 967951 967934 967916 967897 967877 967856 967834 967811 967787 967762 967736 967709 967681 967652 967622 967591 967559 967526 967492 967457 967421 967384 967346 967307 967267 967226 96...

result:

ok All test cases passed. (1 test case)

Test #19:

score: 0
Accepted
time: 42ms
memory: 7040kb

input:

1
991 919

output:

Yes
910729 910728 910726 910723 910719 910714 910708 910701 910693 910684 910674 910663 910651 910638 910624 910609 910593 910576 910558 910539 910519 910498 910476 910453 910429 910404 910378 910351 910323 910294 910264 910233 910201 910168 910134 910099 910063 910026 909988 909949 909909 909868 90...

result:

ok All test cases passed. (1 test case)

Test #20:

score: 0
Accepted
time: 49ms
memory: 7296kb

input:

1
996 1000

output:

Yes
996000 995999 995997 995994 995990 995985 995979 995972 995964 995955 995945 995934 995922 995909 995895 995880 995864 995847 995829 995810 995790 995769 995747 995724 995700 995675 995649 995622 995594 995565 995535 995504 995472 995439 995405 995370 995334 995297 995259 995220 995180 995139 99...

result:

ok All test cases passed. (1 test case)

Test #21:

score: 0
Accepted
time: 46ms
memory: 7296kb

input:

1
1000 1000

output:

Yes
1000000 999999 999997 999994 999990 999985 999979 999972 999964 999955 999945 999934 999922 999909 999895 999880 999864 999847 999829 999810 999790 999769 999747 999724 999700 999675 999649 999622 999594 999565 999535 999504 999472 999439 999405 999370 999334 999297 999259 999220 999180 999139 9...

result:

ok All test cases passed. (1 test case)

Test #22:

score: 0
Accepted
time: 40ms
memory: 3840kb

input:

1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
1...

output:

Yes
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927...

result:

ok All test cases passed. (1000 test cases)

Test #23:

score: 0
Accepted
time: 20ms
memory: 3840kb

input:

1000
1 1000
1 999
1 998
1 997
1 996
1 995
1 994
1 993
1 992
1 991
1 990
1 989
1 988
1 987
1 986
1 985
1 984
1 983
1 982
1 981
1 980
1 979
1 978
1 977
1 976
1 975
1 974
1 973
1 972
1 971
1 970
1 969
1 968
1 967
1 966
1 965
1 964
1 963
1 962
1 961
1 960
1 959
1 958
1 957
1 956
1 955
1 954
1 953
1 952
...

output:

Yes
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927...

result:

ok All test cases passed. (1000 test cases)

Extra Test:

score: 0
Extra Test Passed