QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736676#9615. 骨牌覆盖hos_lyric#25 438ms3968kbC++142.9kb2024-11-12 12:27:002024-11-12 12:27:00

Judging History

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

  • [2024-11-12 12:27:00]
  • 评测
  • 测评结果:25
  • 用时:438ms
  • 内存:3968kb
  • [2024-11-12 12:27:00]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


int N;
vector<Int> A;

bool solve(int L, int R) {
  Int tot[2] = {};
  for (int i = L; i < R; ++i) {
    tot[0] += (A[i] + (~i & 1)) / 2;
    tot[1] += (A[i] + ( i & 1)) / 2;
  }
  if (tot[0] != tot[1]) return false;
  for (int l = L; l < R; ++l) for (int r = l + 1; r <= R; ++r) if (l == L || r == R) {
    auto inside = [&](int i) -> bool {
      return (l <= i && i < r);
    };
    Int ss[2] = {};
    for (int i = L; i < R; ++i) if (inside(i)) {
      ss[0] += (A[i] + (~i & 1)) / 2;
    }
    for (int i = L; i < R; ++i) {
      if (!(i & 1)) {
        Int a = 0;
        if (i - 1 >= L && inside(i - 1)) chmax(a, A[i - 1] / 2 * 2);
        if (i + 1 <  R && inside(i + 1)) chmax(a, A[i + 1] / 2 * 2);
        if (inside(i)) chmax(a, A[i]);
        chmin(a, A[i]);
        ss[1] += a / 2;
      } else {
        Int a = 0;
        if (i - 1 >= L && inside(i - 1)) chmax(a, (A[i - 1] + 1) / 2 * 2 - 1);
        if (i + 1 <  R && inside(i + 1)) chmax(a, (A[i + 1] + 1) / 2 * 2 - 1);
        if (inside(i)) chmax(a, A[i]);
        chmin(a, A[i]);
        ss[1] += (a + 1) / 2;
      }
    }
    if (ss[0] > ss[1]) return false;
  }
  return true;
}

int main() {
  for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
    scanf("%d", &N);
    A.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%lld", &A[i]);
    }
    
    int ans = 0;
    for (int l = 0; l <= N; ++l) for (int r = l + 1; r <= N; ++r) {
      if (solve(l, r)) {
// cerr<<l<<" "<<r<<endl;
        ++ans;
      }
    }
    printf("%d\n", ans);
  }
#ifndef LOCAL
  break;
#endif
  }
  return 0;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 1ms
memory: 3968kb

input:

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

output:

15
24
19
17
31
17
31
15
16
24
21
24
17
16
18
24
24
29
27
16
21
25
17
16
13
23
17
31
22
12
23
27
29
27
25
13
15
23
23
21
25
25
31
16
24
27
31
27
24
15
23
15
23
24
17
7
16
21
29
16
12
16
14
14
29
24
19
29
17
16
29
22
20
23
13
15
25
21
22
27
21
13
24
29
19
16
15
19
21
25
21
20
29
14
14
17
23
10
17
27

result:

ok 100 lines

Test #2:

score: 5
Accepted
time: 1ms
memory: 3776kb

input:

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

output:

19
36
14
29
21
24
13
6
18
37
16
21
17
16
24
14
25
27
21
21
19
18
24
37
16
17
19
21
31
19
16
29
20
29
17
24
12
21
27
27
18
36
20
16
21
12
21
21
15
20
15
27
12
37
25
29
25
24
23
27
16
13
29
19
16
31
16
17
24
27
29
24
18
23
31
31
17
14
12
16
29
29
13
27
10
29
36
13
16
22
12
21
12
29
16
16
19
29
17
29

result:

ok 100 lines

Test #3:

score: 5
Accepted
time: 1ms
memory: 3912kb

input:

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

output:

25
24
22
25
29
21
19
21
29
16
25
19
21
25
20
17
29
21
16
24
11
21
16
24
29
31
14
27
21
19
19
21
37
27
16
28
37
27
24
25
29
28
25
20
29
11
15
23
21
17
13
25
25
10
15
31
17
31
37
21
17
21
37
23
23
17
24
12
16
20
21
10
23
25
31
21
19
25
27
16
27
24
16
24
13
13
21
13
29
18
25
31
22
31
28
28
36
23
29
19

result:

ok 100 lines

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #4:

score: 20
Accepted
time: 1ms
memory: 3848kb

input:

100
10
1 3 1 0 2 2 4 0 1 2
10
3 4 3 5 1 5 4 1 4 5
10
4 5 1 1 2 1 3 2 3 2
10
3 0 3 5 1 0 1 4 5 1
10
1 2 2 2 1 0 1 4 2 0
10
0 3 4 5 5 5 4 2 1 4
10
5 0 0 2 5 4 1 5 3 5
10
5 1 2 2 4 5 1 5 4 3
10
5 3 4 2 1 1 1 1 2 5
10
5 1 4 1 2 1 1 2 2 2
10
1 3 4 2 4 1 4 4 1 2
10
1 0 1 3 0 0 3 3 3 1
10
1 4 0 3 4 0 5 4 0...

output:

23
12
14
9
13
17
13
18
24
18
24
22
12
9
13
16
24
31
17
16
16
21
18
24
25
18
24
21
23
10
29
18
14
36
25
31
29
20
29
21
22
28
9
20
24
12
14
15
10
25
16
14
17
15
29
28
25
17
28
22
12
19
16
12
14
25
13
17
17
16
24
13
18
25
19
16
27
12
14
25
16
28
15
9
10
16
29
25
21
22
12
14
10
21
12
16
9
29
27
25

result:

ok 100 lines

Test #5:

score: 20
Accepted
time: 1ms
memory: 3956kb

input:

100
10
1 1 1 1 0 0 0 0 0 1
10
1 0 0 3 1 2 5 2 3 4
10
1 0 3 1 0 2 5 5 1 4
10
1 0 0 3 2 5 3 3 5 2
10
1 0 3 0 2 1 2 0 3 4
10
1 0 3 3 2 5 4 4 3 3
10
1 1 0 3 0 1 5 2 7 2
10
1 0 3 0 2 1 5 2 1 2
10
1 1 1 0 0 3 0 2 1 0
10
1 0 3 2 5 4 0 2 4 4
10
1 0 1 1 2 1 1 3 1 2
10
1 0 0 0 1 0 0 5 1 1
10
1 0 0 0 3 1 0 1 3...

output:

29
12
18
14
8
16
10
12
11
17
22
13
22
22
8
21
22
8
14
6
17
10
10
13
14
9
21
9
6
28
16
6
8
8
14
9
16
16
9
6
8
8
14
16
13
8
16
8
9
12
9
22
22
21
16
14
13
22
13
13
17
8
10
16
10
8
9
8
6
10
12
13
6
6
13
12
8
8
21
22
16
9
13
13
16
13
24
24
36
16
18
8
21
16
6
13
8
14
8
7

result:

ok 100 lines

Test #6:

score: 20
Accepted
time: 438ms
memory: 3904kb

input:

60
82
5 6 9 8 10 12 8 7 6 5 29 55 5 4 5 10 13 16 14 13 13 16 17 13 16 9 10 12 10 9 8 5 7 3 4 8 6 8 5 60 27 42 5 8 9 7 8 3 72 42 5 6 9 10 11 9 6 8 6 7 9 9 6 8 6 6 8 5 27 18 14 37 4 6 6 7 5 6 24 58 80 54
86
1 6 9 8 10 9 7 9 6 6 9 7 8 6 6 1 64 55 31 64 38 11 80 5 6 9 10 13 11 4 10 9 12 17 17 14 12 16 1...

output:

661
425
776
940
840
1052
439
732
634
1171
728
592
938
1003
636
730
1032
1018
985
893
646
489
650
638
927
626
1192
1442
673
1131
879
760
1086
1079
386
1022
758
1282
648
1019
892
398
1219
585
1054
564
694
1189
1039
931
1310
754
436
525
970
1040
490
584
946
710

result:

ok 60 lines

Test #7:

score: 20
Accepted
time: 139ms
memory: 3904kb

input:

100
56
5 6 9 5 7 10 13 6 12 14 16 9 12 9 7 8 8 9 6 6 6 6 5 9 4 5 8 5 6 3 12 11 14 15 17 14 11 13 13 8 7 6 6 7 8 8 5 6 6 9 7 8 5 18 28 18
42
1 8 9 8 11 13 12 9 8 6 2 8 6 8 6 5 5 6 7 12 11 14 6 7 10 7 9 10 12 9 6 6 6 4 8 5 5 35 4 6 21 10
47
5 6 9 6 10 12 13 11 10 5 9 10 6 9 7 7 9 9 8 4 5 12 7 9 4 9 8 ...

output:

213
304
316
275
636
142
200
283
416
298
265
546
136
341
286
226
194
312
454
138
455
285
205
395
169
451
385
417
295
372
349
256
423
256
473
304
275
531
186
451
580
295
315
372
255
268
294
205
194
394
436
300
409
243
264
247
344
567
355
253
271
383
256
446
289
371
234
404
340
271
402
269
246
236
1794...

result:

ok 100 lines

Test #8:

score: 20
Accepted
time: 147ms
memory: 3900kb

input:

100
45
3 8 7 12 13 14 17 12 21 21 8 17 12 14 12 14 17 13 14 13 12 8 10 10 8 12 12 9 9 7 8 8 6 8 9 9 8 6 8 5 44 34 18 3 5
53
5 8 7 4 11 5 8 10 10 5 9 10 10 9 9 10 11 13 8 9 9 9 9 5 4 6 7 10 13 13 8 8 12 7 6 4 7 7 8 5 11 0 6 7 6 10 7 7 7 6 12 36 14
34
5 8 8 6 6 5 32 11 31 8 3 6 8 8 9 9 7 9 6 8 6 5 19 ...

output:

193
494
214
357
236
454
377
267
349
381
480
433
287
517
280
162
448
499
245
583
299
274
339
196
271
872
394
247
370
354
284
257
305
585
310
696
528
354
349
547
114
328
246
235
405
424
340
341
386
340
446
220
281
252
131
260
356
197
207
546
246
321
332
333
1562
392
383
277
141
331
458
383
254
104
277...

result:

ok 100 lines

Test #9:

score: 20
Accepted
time: 45ms
memory: 3952kb

input:

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

output:

158
163
156
123
319
180
187
183
230
151
515
303
111
335
249
79
146
192
158
145
121
125
169
175
126
158
127
164
115
304
200
413
154
251
157
187
249
221
106
124
200
133
173
122
191
309
406
162
181
241
115
176
114
292
97
128
157
188
99
202
191
143
146
141
175
186
169
179
147
142
170
158
189
117
183
219...

result:

ok 100 lines

Test #10:

score: 20
Accepted
time: 53ms
memory: 3896kb

input:

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

output:

169
116
123
228
159
264
271
284
205
278
149
183
245
276
93
179
265
271
156
128
327
152
221
119
86
126
166
262
217
296
160
168
179
147
151
141
374
197
288
171
693
240
167
234
144
171
251
255
171
197
294
182
202
142
439
173
133
163
115
102
256
172
151
320
183
123
217
214
300
118
139
248
92
225
134
115...

result:

ok 100 lines

Test #11:

score: 20
Accepted
time: 82ms
memory: 3912kb

input:

100
50
51 24 2 38 28 31 51 54 50 31 80 52 34 48 29 22 61 79 0 0 70 68 80 1 75 37 52 49 50 22 36 5 19 91 9 15 64 27 77 29 32 19 72 85 70 42 37 65 48 15
50
76 88 7 46 55 87 61 25 11 14 1 26 83 41 58 32 49 41 9 9 59 35 51 19 50 32 49 57 78 20 19 53 49 60 29 28 17 27 77 80 12 30 46 89 88 18 100 63 40 84...

output:

201
222
211
110
292
371
227
184
239
223
248
293
185
172
175
419
219
185
282
286
234
505
199
126
274
239
274
236
208
223
190
306
303
270
251
397
269
275
280
226
325
262
377
285
223
266
326
286
257
171
406
257
262
394
342
268
187
203
374
169
310
276
248
148
494
136
248
242
182
341
201
279
233
280
362
...

result:

ok 100 lines

Test #12:

score: 20
Accepted
time: 28ms
memory: 3812kb

input:

100
50
1 0 0 1 2 0 1 1 5 0 7 2 7 0 3 6 7 6 5 5 12 5 17 8 17 4 3 13 4 2 16 16 13 8 14 6 22 17 19 20 16 19 0 11 22 28 25 4 33 10
50
1 0 0 3 0 1 0 1 7 7 5 7 2 7 6 3 0 8 8 13 5 1 3 0 5 7 0 17 7 2 0 6 16 11 5 6 15 14 2 11 11 18 19 16 5 18 22 3 11 20
50
1 0 3 2 1 3 3 0 7 4 4 0 1 2 11 6 9 8 9 7 14 17 2 16 ...

output:

150
177
114
65
109
150
113
74
96
84
166
138
135
108
108
216
114
116
108
269
113
103
108
162
213
118
115
139
117
106
138
99
117
54
98
95
192
83
127
114
82
154
92
168
118
124
119
110
133
131
162
152
173
75
117
173
114
156
165
69
158
152
122
123
124
168
115
131
94
125
104
175
60
107
124
140
109
128
124...

result:

ok 100 lines

Test #13:

score: 20
Accepted
time: 29ms
memory: 3824kb

input:

100
50
1 1 0 3 0 3 2 5 2 7 9 5 1 6 0 9 1 6 11 0 3 3 0 13 4 11 16 19 14 9 12 5 20 1 16 6 18 19 4 23 8 0 1 3 30 6 30 31 6 2
50
1 1 0 3 3 1 0 0 5 3 2 2 4 1 1 0 3 6 6 9 8 1 0 7 9 3 12 5 0 15 14 2 4 1 13 19 3 12 18 6 21 20 13 17 9 18 15 11 10 10
50
1 1 0 0 1 0 5 2 1 6 1 0 11 4 2 8 8 3 1 3 3 0 0 3 5 3 5 2...

output:

76
137
198
119
192
106
105
116
157
75
91
119
98
118
100
86
124
160
323
115
163
138
115
114
75
69
143
200
121
92
98
104
93
85
161
111
208
156
139
90
93
191
111
115
190
150
133
97
152
65
82
131
99
310
74
90
108
71
104
99
181
118
96
137
97
114
88
113
91
128
143
111
81
110
130
190
111
149
171
239
96
133...

result:

ok 100 lines

Subtask #3:

score: 0
Time Limit Exceeded

Dependency #2:

100%
Accepted

Test #14:

score: 0
Time Limit Exceeded

input:

5
813
5 6 5 12 11 14 17 15 14 12 17 18 20 9 16 14 14 12 16 11 13 16 13 14 21 14 21 17 19 21 22 20 14 19 19 21 16 10 10 15 14 12 17 17 10 10 15 17 15 16 16 13 17 13 15 15 14 12 8 10 16 11 13 2 17 16 18 12 18 17 9 17 15 17 14 9 13 14 15 6 21 20 12 17 19 18 22 9 20 14 19 19 20 20 20 15 17 10 19 20 22 2...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%