QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#116067#5280. Depot RearrangementHe_Ren#35 27ms26448kbC++171.3kb2023-06-28 08:48:482024-05-31 14:20:15

Judging History

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

  • [2024-05-31 14:20:15]
  • 评测
  • 测评结果:35
  • 用时:27ms
  • 内存:26448kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-28 08:48:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 800 + 5;

vector<pii> g[MAXN];

vector<int> sta;
int cur[MAXN];

void dfs(int u)
{
	while(cur[u] < (int)g[u].size())
	{
		int i = cur[u]; ++cur[u];
		
		dfs(g[u][i].first);
		
		if(g[u][i].second > 0)
			sta.emplace_back(g[u][i].second);
	}
}

int main(void)
{
	int n,m;
	scanf("%d%d",&n,&m);
	
	for(int i=1; i<=n; ++i)
	{
		static vector<int> pos[MAXN];
		for(int j=1; j<=m; ++j)
			pos[j].clear();
		for(int j=1; j<=m; ++j)
		{
			int x;
			scanf("%d",&x);
			pos[x].emplace_back(i * (m-1) + j);
		}
		
		for(int j=1; j<=m; ++j)
		{
			if((int)pos[j].size() == 1) continue;
			if((int)pos[j].size() > 1)
			{
				for(int k=1; k<(int)pos[j].size(); ++k)
					g[i].emplace_back(j + n, pos[j][k]);
			}
			else
			{
				g[j + n].emplace_back(i, -1);
			}
		}
	}
	
	vector<pii> ans;
	
	int lstpos = n * m + 1;
	auto OP = [&] (int i)
	{
		ans.emplace_back(i, lstpos);
		lstpos = i;
	};
	
	for(int rt=1; rt<=n; ++rt)
	{
		sta.clear();
		dfs(rt);
		if((int)sta.size() == 0) continue;
		
		for(auto t: sta)
			OP(t);
		OP(n * m + 1);
	}
	
	printf("%d\n",(int)ans.size());
	for(auto t: ans)
		printf("%d %d\n",t.first,t.second);
	return 0;
}

详细

Test #1:

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

input:

10 3
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3


output:

0

result:

ok both subtasks are correct!

Test #2:

score: 2
Acceptable Answer
time: 0ms
memory: 3812kb

input:

5 4
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4


output:

13
19 21
13 19
18 13
10 18
15 10
9 15
17 9
7 17
14 7
6 14
11 6
5 11
21 5

result:

points 0.40 first subtask is correct but plan is wrong.

Test #3:

score: 2
Acceptable Answer
time: 0ms
memory: 4096kb

input:

10 10
8 10 10 3 7 3 5 6 1 4 3 8 2 9 1 8 4 2 7 3 10 7 9 2 1 10 10 9 1 2 9 7 4 5 2 9 10 5 7 6 6 8 6 8 4 2 9 1 2 8 6 1 4 2 2 1 5 6 3 10 10 7 9 4 8 9 8 2 5 6 4 3 1 6 3 3 10 7 7 5 3 6 8 5 9 4 6 7 9 4 10 5 3 4 5 1 1 7 8 5


output:

32
90 101
34 90
100 34
62 100
81 62
55 81
95 55
59 95
49 59
33 49
88 33
97 88
69 97
78 69
42 78
70 42
60 70
35 60
91 35
37 91
24 37
48 24
77 48
54 77
45 54
28 45
12 28
26 12
44 26
36 44
15 36
101 15

result:

points 0.40 first subtask is correct but plan is wrong.

Test #4:

score: 2
Acceptable Answer
time: 0ms
memory: 4120kb

input:

100 10
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 9 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10...

output:

19
417 1001
175 417
742 175
864 742
333 864
707 333
613 707
757 613
167 757
199 167
775 199
670 775
651 670
747 651
108 747
1001 108
682 1001
646 682
1001 646

result:

points 0.40 first subtask is correct but plan is wrong.

Test #5:

score: 2
Acceptable Answer
time: 1ms
memory: 3876kb

input:

200 100
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 ...

output:

195
16111 20001
16767 16111
6366 16767
17156 6366
15510 17156
16302 15510
18876 16302
7097 18876
17696 7097
9994 17696
18810 9994
19092 18810
19585 19092
4537 19585
18878 4537
18693 18878
10377 18693
18381 10377
18010 18381
18406 18010
10483 18406
18403 10483
2937 18403
17193 2937
19433 17193
12702 ...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #6:

score: 2
Acceptable Answer
time: 1ms
memory: 4140kb

input:

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

output:

1401
3700 4021
3834 3700
3814 3834
3839 3814
3812 3839
3755 3812
3798 3755
3738 3798
3787 3738
3763 3787
3737 3763
3820 3737
3660 3820
3723 3660
3734 3723
3779 3734
3628 3779
3732 3628
3819 3732
3801 3819
3663 3801
3624 3663
3800 3624
3581 3800
3759 3581
3698 3759
3590 3698
3620 3590
3564 3620
3605 ...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #7:

score: 2
Acceptable Answer
time: 5ms
memory: 4164kb

input:

300 300
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 ...

output:

205
72719 90001
75780 72719
37319 75780
87884 37319
84894 87884
35865 84894
60643 35865
87217 60643
88795 87217
6145 88795
40472 6145
69777 40472
15658 69777
49829 15658
15743 49829
6087 15743
16627 6087
22607 16627
80228 22607
22521 80228
88669 22521
20227 88669
80013 20227
66558 80013
81437 66558
...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #8:

score: 2
Acceptable Answer
time: 3ms
memory: 6164kb

input:

301 40
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

11624
11779 12041
11467 11779
11740 11467
11428 11740
11701 11428
11389 11701
11662 11389
11350 11662
11623 11350
11311 11623
11584 11311
11272 11584
11545 11272
11233 11545
11778 11233
11155 11778
11194 11155
11739 11194
11154 11739
11700 11154
11116 11700
11661 11116
11077 11661
11622 11077
11038 ...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #9:

score: 2
Acceptable Answer
time: 2ms
memory: 6692kb

input:

400 100
11 65 1 79 15 18 79 46 9 30 71 53 58 55 94 73 39 16 6 91 49 30 23 30 28 81 90 48 97 54 79 30 94 18 42 77 44 36 5 48 55 97 79 36 41 59 79 71 32 59 3 10 63 52 44 41 9 46 31 31 56 87 60 80 12 51 15 78 41 65 95 34 29 83 46 64 37 53 98 17 41 45 36 73 20 53 48 80 57 54 57 72 39 56 98 6 10 78 11 72...

output:

14592
39402 40001
39683 39402
39292 39683
39658 39292
39334 39658
39074 39334
39501 39074
38985 39501
39652 38985
38881 39652
39181 38881
39000 39181
38676 39000
39499 38676
39291 39499
39329 39291
38279 39329
39634 38279
39164 39634
38731 39164
39688 38731
38755 39688
39568 38755
38746 39568
39477 ...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #10:

score: 0
Wrong Answer
time: 1ms
memory: 4196kb

input:

40 160
17 2 3 4 5 6 7 91 9 10 154 12 103 14 15 16 17 25 19 58 21 8 23 24 52 26 27 58 120 105 50 55 104 32 35 36 37 38 45 10 41 42 43 44 45 71 47 48 49 34 140 52 53 54 115 44 28 58 59 60 61 62 63 64 132 66 67 68 69 70 71 69 24 74 75 76 77 133 79 80 81 82 100 84 31 86 87 88 100 90 91 92 93 94 95 96 97...

output:

1316
5549 6401
5723 5549
6359 5723
6520 6359
5590 6520
6043 5590
6352 6043
4924 6352
6040 4924
4767 6040
5247 4767
3181 5247
5878 3181
6035 5878
4293 6035
5565 4293
3972 5565
5561 3972
6513 5561
5551 6513
3010 5551
4692 3010
5086 4692
6202 5086
4917 6202
3499 4917
5543 3499
4274 5543
5245 4274
6030 ...

result:

wrong answer Integer 6520 violates the range [1, 6401]

Test #11:

score: 2
Acceptable Answer
time: 5ms
memory: 6772kb

input:

400 100
88 82 9 2 90 1 83 32 32 79 8 79 63 67 85 82 50 63 69 2 7 91 21 90 69 3 39 78 66 83 96 53 24 65 56 63 90 54 35 55 94 22 76 12 54 55 5 49 91 73 8 19 64 54 39 23 13 27 34 4 81 52 13 11 36 45 3 50 82 81 42 50 75 15 99 70 29 26 70 66 34 15 42 83 16 19 19 12 76 1 68 49 7 17 64 37 98 34 99 37 34 64...

output:

14611
39497 40001
39574 39497
39426 39574
39636 39426
39360 39636
39695 39360
39478 39695
39368 39478
39656 39368
39476 39656
39694 39476
39270 39694
39362 39270
38973 39362
39342 38973
39692 39342
39096 39692
39255 39096
38657 39255
39241 38657
38302 39241
39223 38302
39684 39223
39359 39684
39074 ...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #12:

score: 2
Acceptable Answer
time: 1ms
memory: 4656kb

input:

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

output:

4260
5739 6021
5435 5739
5701 5435
5416 5701
5682 5416
5397 5682
5661 5397
5378 5661
5644 5378
5358 5644
5625 5358
5339 5625
5606 5339
5321 5606
5549 5321
5302 5549
5530 5302
5283 5530
5492 5283
5226 5492
5737 5226
5148 5737
5188 5148
5720 5188
5131 5720
5169 5131
5700 5169
5147 5700
5681 5147
5130 ...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #13:

score: 2
Acceptable Answer
time: 12ms
memory: 9768kb

input:

300 300
215 159 263 206 201 183 286 56 142 10 231 214 34 54 263 250 169 208 239 148 104 22 244 17 74 68 184 52 2 30 42 83 222 106 25 152 37 225 213 213 69 273 91 221 207 48 166 28 221 50 46 64 10 254 207 109 206 144 270 291 195 197 253 235 141 186 102 68 52 24 38 6 181 44 256 200 77 233 285 163 223 ...

output:

32648
89594 90001
89400 89594
89986 89400
88742 89986
89998 88742
89695 89998
86705 89695
89692 86705
89912 89692
89372 89912
87901 89372
88204 87901
88789 88204
89563 88789
88041 89563
89493 88041
89083 89493
89664 89083
88779 89664
86708 88779
89256 86708
88632 89256
88483 88632
89623 88483
89906 ...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #14:

score: 0
Wrong Answer
time: 13ms
memory: 16308kb

input:

201 400
1 1 1 1 1 152 1 1 1 1 1 1 1 33 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 300 154 1 1 147 1 1 1 383 186 1 1 90 256 1 1 1 1 1 1 1 63 1 1 1 1 208 1 1 1 1 31 1 1 1 1 1 1 1 127 1 1 29 216 397 393 1 1 1 1 1 1 279 1 1 1 1 55 1 1 215 249 1 1 1 1 1 1 172 1 1 1 1 1 1 1 1 1 1 1 1 349 1 331 1 1 1 1 1 1 1 34...

output:

63990
80599 80401
80198 80599
79401 80198
79801 79401
78760 79801
79400 78760
80200 79400
78604 80200
80199 78604
80597 80199
79003 80597
79800 79003
78603 79800
79398 78603
80592 79398
78205 80592
79798 78205
80197 79798
79001 80197
80591 79001
79797 80591
79000 79797
78204 79000
79397 78204
78602 ...

result:

wrong answer Integer 80599 violates the range [1, 80401]

Test #15:

score: 2
Acceptable Answer
time: 5ms
memory: 4156kb

input:

400 400
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 ...

output:

217
118887 160001
1182 118887
160001 1182
147603 160001
133486 147603
87517 133486
132178 87517
148583 132178
134992 148583
126998 134992
143756 126998
110254 143756
119855 110254
54228 119855
117270 54228
139614 117270
138055 139614
152606 138055
133853 152606
34502 133853
83272 34502
34594 83272
1...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #16:

score: 2
Acceptable Answer
time: 9ms
memory: 8332kb

input:

301 200
50 129 146 60 183 51 47 77 26 73 1 45 1 44 149 1 81 196 17 16 163 35 159 71 1 94 161 138 138 27 76 1 102 42 5 186 176 1 111 198 37 63 81 155 95 164 132 135 155 194 126 98 31 34 121 19 175 148 33 105 25 122 91 165 1 69 1 197 12 98 1 155 5 53 42 1 60 98 78 61 155 13 1 171 102 152 95 61 87 200 ...

output:

23506
56909 60201
58276 56909
59694 58276
59479 59694
59689 59479
60084 59689
58879 60084
59673 58879
58682 59673
59294 58682
59879 59294
58181 59879
58877 58181
58090 58877
58867 58090
57099 58867
59063 57099
56490 59063
59662 56490
58287 59662
59268 58287
55959 59268
58086 55959
59094 58086
58278 ...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #17:

score: 0
Wrong Answer
time: 16ms
memory: 18868kb

input:

201 400
1 1 1 1 1 1 1 1 1 1 1 1 1 263 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 246 1 1 1 1 1 1 1 1 1 1 1 1 1 1 107 1 1 1 1 1 1 1 1 57 1 1 1 1 1 1 1 224 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 90 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

77869
80599 80401
79801 80599
79003 79801
79800 79003
80200 79800
80598 80200
78604 80598
79799 78604
80596 79799
80198 80596
78603 80198
79002 78603
80595 79002
79797 80595
80197 79797
79796 80197
78602 79796
80594 78602
78205 80594
80593 78205
77806 80593
80592 77806
77407 80592
80591 77407
77008 ...

result:

wrong answer Integer 80599 violates the range [1, 80401]

Test #18:

score: 2
Acceptable Answer
time: 12ms
memory: 12224kb

input:

400 300
75 26 289 176 131 196 124 8 230 157 247 265 13 2 210 141 17 200 187 83 21 22 118 144 232 26 284 75 48 30 132 32 65 34 72 36 73 286 164 40 41 261 65 270 221 12 139 48 49 143 91 39 17 258 275 56 151 194 282 55 228 266 296 64 22 232 67 142 69 152 10 102 109 45 75 49 283 112 78 283 81 236 169 22...

output:

43105
118698 120001
118250 118698
118904 118250
115956 118904
117769 115956
118699 117769
118103 118699
119555 118103
118396 119555
114515 118396
117193 114515
113621 117193
117077 113621
116288 117077
119882 116288
117203 119882
113215 117203
115712 113215
116861 115712
116246 116861
112424 116246
...

result:

points 0.40 first subtask is correct but plan is wrong.

Test #19:

score: 0
Wrong Answer
time: 27ms
memory: 26448kb

input:

333 399
1 1 1 1 1 1 1 28 1 1 1 1 1 1 161 1 17 1 1 1 1 262 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 43 1 1 1 1 1 70 1 1 1 142 1 1 1 1 1 1 1 1 1 1 1 1 70 1 1 1 1 1 1 278 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 245 1 1 1 1 1 1 33 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 106 1 1 1 1 268 1 1 1 172 1 1 1 1 1 312 1 286 1 1 1 1 ...

output:

114795
132933 132868
131739 132933
132535 131739
132931 132535
132135 132931
132930 132135
131341 132930
132534 131341
131738 132534
132928 131738
130943 132928
132533 130943
130545 132533
132531 130545
131340 132531
131736 131340
132134 131736
131339 132134
132927 131339
130146 132927
132530 130146...

result:

wrong answer Integer 132933 violates the range [1, 132868]

Test #20:

score: 2
Acceptable Answer
time: 18ms
memory: 14644kb

input:

400 400
100 35 353 385 317 228 7 148 113 165 11 306 209 89 21 166 17 2 19 249 27 305 377 22 3 353 38 28 29 96 191 32 33 309 35 308 100 176 152 40 176 42 43 86 45 46 96 48 396 381 218 246 53 54 334 159 243 360 294 60 33 62 185 64 65 66 191 121 351 107 10 343 367 74 75 201 77 247 79 134 304 92 42 126 ...

output:

55816
153444 160001
159160 153444
160000 159160
157798 160000
158801 157798
159997 158801
158397 159997
158797 158397
158203 158797
159519 158203
155606 159519
156233 155606
158601 156233
154813 158601
159595 154813
155158 159595
156585 155158
159026 156585
159991 159026
156401 159991
156008 156401
...

result:

points 0.40 first subtask is correct but plan is wrong.