QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#736666#9615. 骨牌覆盖hos_lyric#5 14ms3916kbC++142.8kb2024-11-12 12:22:082024-11-12 12:22:09

Judging History

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

  • [2024-11-12 12:22:09]
  • 评测
  • 测评结果:5
  • 用时:14ms
  • 内存:3916kb
  • [2024-11-12 12:22:08]
  • 提交

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 p = 0; p < 1 << (R - L); ++p) {
    Int ss[2] = {};
    for (int i = L; i < R; ++i) if (p >> (i - L) & 1) {
      ss[0] += (A[i] + (~i & 1)) / 2;
    }
    for (int i = L; i < R; ++i) {
      if (!(i & 1)) {
        Int a = 0;
        if (i - 1 >= L && (p >> (i - 1 - L) & 1)) chmax(a, A[i - 1] / 2 * 2);
        if (i + 1 <  R && (p >> (i + 1 - L) & 1)) chmax(a, A[i + 1] / 2 * 2);
        if (p >> (i - L) & 1) chmax(a, A[i]);
        chmin(a, A[i]);
        ss[1] += a / 2;
      } else {
        Int a = 0;
        if (i - 1 >= L && (p >> (i - 1 - L) & 1)) chmax(a, (A[i - 1] + 1) / 2 * 2 - 1);
        if (i + 1 <  R && (p >> (i + 1 - L) & 1)) chmax(a, (A[i + 1] + 1) / 2 * 2 - 1);
        if (p >> (i - L) & 1) 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;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 11ms
memory: 3916kb

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: 12ms
memory: 3780kb

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: 14ms
memory: 3904kb

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: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Test #4:

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

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: 3ms
memory: 3892kb

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: 0
Time Limit Exceeded

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:


result:


Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%