Toggle navigation
Bulletin
Problems
Submissions
Contests
Discuss
About
Rank
Sign in
Sign up
×
Close
2022 全國模擬賽題目上線啦 !!!!!
題目在
這裡
~
2023 全國模擬賽題目上線啦 !!!!!
題目在
這裡
~
2024 全國模擬賽題目上線啦 !!!!!
題目在
這裡
~
2250 . E. 間諜
Submit
Status
Discussion / Solution
Ranklist
Back to Problems List
TopCoder
Caido
$\mathbb{W}\mathcal{aimai}\sim$
User's AC Ratio
39.1% (
18/46
)
Submission's AC Ratio
13.7% (
30
/
219
)
Tags
Show solution-related tags
TOI
TOI-pre
2022-TOI-pre
Description
題目 PDF 檔在這裡
Input Format
Output Format
Sample Input 1
copy
3 3
Sample Output 1
copy
-1
Sample Input 2
copy
4 3
Sample Output 2
copy
4 2
2 1
3 3
1 2
3 1
4 3
2 2
4 1
1 3
3 2
1 1
2 3
4 2
Hints
Problem Source
2022 TOI 初選
測資來源:
TWPCA GitHub
Subtasks
No.
Testdata Range
Constraints
Score
1
0~1
範例測資。
0
2
2~20
$nm \le 16$
7
3
21~99
$n = 2$ 或 $m = 2$
35
4
100~186
$n \ge 12$ 且 $m \ge 12$
47
5
187~222
無額外限制。
11
Testdata and Limits
No.
Time Limit (ms)
Memory Limit (VSS, KiB)
Output Limit (KiB)
Subtasks
0
500
1048576
65536
1
1
500
1048576
65536
1
2
500
1048576
65536
2
3
500
1048576
65536
2
4
500
1048576
65536
2
5
500
1048576
65536
2
6
500
1048576
65536
2
7
500
1048576
65536
2
8
500
1048576
65536
2
9
500
1048576
65536
2
10
500
1048576
65536
2
11
500
1048576
65536
2
12
500
1048576
65536
2
13
500
1048576
65536
2
14
500
1048576
65536
2
15
500
1048576
65536
2
16
500
1048576
65536
2
17
500
1048576
65536
2
18
500
1048576
65536
2
19
500
1048576
65536
2
20
500
1048576
65536
2
21
500
1048576
65536
3
22
500
1048576
65536
3
23
500
1048576
65536
3
24
500
1048576
65536
3
25
500
1048576
65536
3
26
500
1048576
65536
3
27
500
1048576
65536
3
28
500
1048576
65536
3
29
500
1048576
65536
3
30
500
1048576
65536
3
31
500
1048576
65536
3
32
500
1048576
65536
3
33
500
1048576
65536
3
34
500
1048576
65536
3
35
500
1048576
65536
3
36
500
1048576
65536
3
37
500
1048576
65536
3
38
500
1048576
65536
3
39
500
1048576
65536
3
40
500
1048576
65536
3
41
500
1048576
65536
3
42
500
1048576
65536
3
43
500
1048576
65536
3
44
500
1048576
65536
3
45
500
1048576
65536
3
46
500
1048576
65536
3
47
500
1048576
65536
3
48
500
1048576
65536
3
49
500
1048576
65536
3
50
500
1048576
65536
3
51
500
1048576
65536
3
52
500
1048576
65536
3
53
500
1048576
65536
3
54
500
1048576
65536
3
55
500
1048576
65536
3
56
500
1048576
65536
3
57
500
1048576
65536
3
58
500
1048576
65536
3
59
500
1048576
65536
3
60
500
1048576
65536
3
61
500
1048576
65536
3
62
500
1048576
65536
3
63
500
1048576
65536
3
64
500
1048576
65536
3
65
500
1048576
65536
3
66
500
1048576
65536
3
67
500
1048576
65536
3
68
500
1048576
65536
3
69
500
1048576
65536
3
70
500
1048576
65536
3
71
500
1048576
65536
3
72
500
1048576
65536
3
73
500
1048576
65536
3
74
500
1048576
65536
3
75
500
1048576
65536
3
76
500
1048576
65536
3
77
500
1048576
65536
3
78
500
1048576
65536
3
79
500
1048576
65536
3
80
500
1048576
65536
3
81
500
1048576
65536
3
82
500
1048576
65536
3
83
500
1048576
65536
3
84
500
1048576
65536
3
85
500
1048576
65536
3
86
500
1048576
65536
3
87
500
1048576
65536
3
88
500
1048576
65536
3
89
500
1048576
65536
3
90
500
1048576
65536
3
91
500
1048576
65536
3
92
500
1048576
65536
3
93
500
1048576
65536
3
94
500
1048576
65536
3
95
500
1048576
65536
3
96
500
1048576
65536
3
97
500
1048576
65536
3
98
500
1048576
65536
3
99
500
1048576
65536
3
100
500
1048576
65536
4
101
500
1048576
65536
4
102
500
1048576
65536
4
103
500
1048576
65536
4
104
500
1048576
65536
4
105
500
1048576
65536
4
106
500
1048576
65536
4
107
500
1048576
65536
4
108
500
1048576
65536
4
109
500
1048576
65536
4
110
500
1048576
65536
4
111
500
1048576
65536
4
112
500
1048576
65536
4
113
500
1048576
65536
4
114
500
1048576
65536
4
115
500
1048576
65536
4
116
500
1048576
65536
4
117
500
1048576
65536
4
118
500
1048576
65536
4
119
500
1048576
65536
4
120
500
1048576
65536
4
121
500
1048576
65536
4
122
500
1048576
65536
4
123
500
1048576
65536
4
124
500
1048576
65536
4
125
500
1048576
65536
4
126
500
1048576
65536
4
127
500
1048576
65536
4
128
500
1048576
65536
4
129
500
1048576
65536
4
130
500
1048576
65536
4
131
500
1048576
65536
4
132
500
1048576
65536
4
133
500
1048576
65536
4
134
500
1048576
65536
4
135
500
1048576
65536
4
136
500
1048576
65536
4
137
500
1048576
65536
4
138
500
1048576
65536
4
139
500
1048576
65536
4
140
500
1048576
65536
4
141
500
1048576
65536
4
142
500
1048576
65536
4
143
500
1048576
65536
4
144
500
1048576
65536
4
145
500
1048576
65536
4
146
500
1048576
65536
4
147
500
1048576
65536
4
148
500
1048576
65536
4
149
500
1048576
65536
4
150
500
1048576
65536
4
151
500
1048576
65536
4
152
500
1048576
65536
4
153
500
1048576
65536
4
154
500
1048576
65536
4
155
500
1048576
65536
4
156
500
1048576
65536
4
157
500
1048576
65536
4
158
500
1048576
65536
4
159
500
1048576
65536
4
160
500
1048576
65536
4
161
500
1048576
65536
4
162
500
1048576
65536
4
163
500
1048576
65536
4
164
500
1048576
65536
4
165
500
1048576
65536
4
166
500
1048576
65536
4
167
500
1048576
65536
4
168
500
1048576
65536
4
169
500
1048576
65536
4
170
500
1048576
65536
4
171
500
1048576
65536
4
172
500
1048576
65536
4
173
500
1048576
65536
4
174
500
1048576
65536
4
175
500
1048576
65536
4
176
500
1048576
65536
4
177
500
1048576
65536
4
178
500
1048576
65536
4
179
500
1048576
65536
4
180
500
1048576
65536
4
181
500
1048576
65536
4
182
500
1048576
65536
4
183
500
1048576
65536
4
184
500
1048576
65536
4
185
500
1048576
65536
4
186
500
1048576
65536
4
187
500
1048576
65536
5
188
500
1048576
65536
5
189
500
1048576
65536
5
190
500
1048576
65536
5
191
500
1048576
65536
5
192
500
1048576
65536
5
193
500
1048576
65536
5
194
500
1048576
65536
5
195
500
1048576
65536
5
196
500
1048576
65536
5
197
500
1048576
65536
5
198
500
1048576
65536
5
199
500
1048576
65536
5
200
500
1048576
65536
5
201
500
1048576
65536
5
202
500
1048576
65536
5
203
500
1048576
65536
5
204
500
1048576
65536
5
205
500
1048576
65536
5
206
500
1048576
65536
5
207
500
1048576
65536
5
208
500
1048576
65536
5
209
500
1048576
65536
5
210
500
1048576
65536
5
211
500
1048576
65536
5
212
500
1048576
65536
5
213
500
1048576
65536
5
214
500
1048576
65536
5
215
500
1048576
65536
5
216
500
1048576
65536
5
217
500
1048576
65536
5
218
500
1048576
65536
5
219
500
1048576
65536
5
220
500
1048576
65536
5
221
500
1048576
65536
5
222
500
1048576
65536
5
Submit
Back to Top