QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#123972#89. Restore ArrayQwerty1232#7 15ms3848kbC++171.3kb2023-07-14 02:12:542024-07-04 00:38:36

Judging History

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

  • [2024-07-04 00:38:36]
  • 评测
  • 测评结果:7
  • 用时:15ms
  • 内存:3848kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-14 02:12:54]
  • 提交

answer

#include <bits/stdc++.h>

int32_t main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n, m;
    std::cin >> n >> m;
    std::vector<std::array<int, 4>> input(m);
    for (auto& [l, r, k, val] : input) {
        std::cin >> l >> r >> k >> val;
        r++;
        k--;
    }

    auto check = [&](std::vector<int> ans) {
        bool fail = false;
        for (auto& [l, r, k, val] : input) {
            int sum = std::accumulate(ans.begin() + l, ans.begin() + r, 0);
            if (val == 0) {
                fail = fail || ((r - l) - sum <= k);
            } else {
                fail = fail || (sum < (r - l) - k);
            }
            if (fail) {
                break;
            }
        }
        return !fail;
    };

    if (n <= 18) {
        for (int mask = 0; mask < (1 << n); mask++) {
            std::vector<int> ans(n);
            for (int j = 0; j < n; j++) {
                ans[j] = (mask >> j) & 1;
            }
            if (check(ans)) {
                for (int i = 0; i < n; i++) {
                    std::cout << ans[i] << " \n"[i == n - 1];
                }
                return 0;
            }
        }
        std::cout << "-1\n";
    }

    return 0;
}

詳細信息

Subtask #1:

score: 7
Accepted

Test #1:

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

input:

8 13
0 1 2 1
3 5 1 1
5 7 2 1
0 2 2 0
2 5 3 1
3 7 4 1
2 2 1 0
0 1 1 0
2 7 5 1
2 4 1 0
0 4 2 0
4 5 2 1
1 2 1 0

output:

1 0 0 1 1 1 1 0

result:

ok your plan is correct!

Test #2:

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

input:

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

output:

1 0 0 0 1 0 0

result:

ok your plan is correct!

Test #3:

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

input:

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

output:

0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0

result:

ok your plan is correct!

Test #4:

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

input:

17 195
12 16 3 1
5 7 3 1
2 10 5 1
5 7 2 1
4 10 7 1
3 9 4 1
8 13 5 1
4 9 2 1
2 7 5 1
1 5 2 1
5 12 3 1
10 13 3 1
5 7 3 1
1 3 3 1
0 9 2 1
3 16 7 1
3 6 3 1
14 16 2 1
3 8 3 1
1 1 1 1
2 15 14 1
1 6 4 1
4 8 1 0
1 2 2 1
4 12 9 1
4 4 1 0
7 13 2 0
2 11 2 0
5 16 2 0
0 3 4 1
9 10 2 1
13 14 2 1
3 8 3 1
11 14 3 1...

output:

1 1 1 1 0 1 1 1 1 1 0 1 0 1 1 1 0

result:

ok your plan is correct!

Test #5:

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

input:

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

output:

-1

result:

ok No Solution!

Test #6:

score: 0
Accepted
time: 4ms
memory: 3600kb

input:

17 195
0 9 10 1
2 11 1 0
4 6 1 0
4 11 1 0
16 16 1 1
4 5 2 1
0 3 1 1
2 12 5 1
2 13 4 0
8 15 3 1
2 3 2 1
6 12 6 0
5 11 3 1
10 16 4 0
12 13 1 1
3 15 6 1
9 14 6 1
2 10 3 0
1 13 3 1
4 7 1 0
0 4 2 1
0 10 9 1
5 14 5 1
1 6 5 1
5 6 2 1
9 14 5 0
1 6 2 1
0 14 7 0
5 6 1 0
12 14 2 0
2 7 4 0
0 4 4 0
12 14 1 0
1 7...

output:

-1

result:

ok No Solution!

Test #7:

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

input:

16 181
6 7 2 1
4 12 2 0
6 12 6 1
8 8 1 0
4 14 3 0
1 12 5 0
15 15 1 1
9 13 4 0
6 7 2 1
2 12 5 0
5 11 7 1
2 4 2 1
4 5 2 1
10 11 2 0
14 14 1 1
9 14 1 0
3 5 2 1
7 11 4 0
6 13 8 1
5 8 4 1
3 11 7 1
3 13 5 0
9 10 2 0
6 11 4 0
3 8 3 0
13 14 2 1
9 11 2 0
5 8 1 0
4 9 4 0
2 2 1 0
1 13 1 0
2 11 5 0
5 14 4 0
0 3...

output:

0 1 0 1 1 0 1 0 0 0 0 0 1 0 1 1

result:

ok your plan is correct!

Test #8:

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

input:

16 172
10 15 1 0
11 12 1 0
3 9 5 1
7 11 5 1
8 10 1 0
5 10 4 0
1 15 11 1
9 11 3 0
4 13 7 0
1 3 2 0
5 10 4 0
7 15 8 1
3 11 4 0
9 15 4 0
7 15 6 0
7 10 3 0
7 13 6 0
8 13 6 1
3 9 4 0
5 9 5 1
7 8 1 0
1 14 4 0
10 14 4 0
11 15 2 0
2 13 6 0
6 11 1 0
1 10 10 1
10 12 1 0
2 10 8 1
5 8 3 0
3 11 4 0
10 10 1 0
3 1...

output:

1 0 0 1 1 0 0 0 1 0 0 0 0 0 1 1

result:

ok your plan is correct!

Test #9:

score: 0
Accepted
time: 12ms
memory: 3608kb

input:

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

output:

1 0 0 0 1 1 1 1 0 1 1 1 0 0 1 1 1 1

result:

ok your plan is correct!

Test #10:

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

input:

17 6
1 1 1 0
2 3 1 0
0 0 1 1
2 13 8 1
6 8 1 0
2 5 2 0

output:

1 0 1 0 1 0 1 1 0 1 0 0 0 0 0 0 0

result:

ok your plan is correct!

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 2ms
memory: 3612kb

input:

4992 9040
331 4442 1 0
3489 4173 1 0
393 4420 1 0
1324 2666 1 0
1317 4131 1 0
399 3010 1 0
1843 4154 1 0
1119 4876 1 0
4216 4980 1 0
2003 4370 1 0
769 1927 1 0
934 3414 1 0
2072 2507 1 0
215 3526 1 0
1493 4107 1 0
539 1643 1 0
2783 4338 1 0
967 1190 1 0
1374 2868 1 0
34 1378 1 0
71 1418 1 0
2120 223...

output:


result:

wrong output format Unexpected end of file - int32 expected

Subtask #3:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #17:

score: 0
Wrong Answer
time: 2ms
memory: 3848kb

input:

4938 9881
1814 3083 1 0
2918 2958 41 1
2085 2909 825 1
2595 3342 748 1
1147 2469 1323 1
2697 2734 1 0
407 4791 1 0
568 2847 1 0
2500 2905 1 0
1670 3662 1 0
1692 3400 1709 1
35 436 402 1
1393 2755 1 0
1074 4777 3704 1
552 1519 1 0
3216 3566 351 1
1841 2502 1 0
3 1708 1706 1
90 3062 1 0
1593 2428 1 0
...

output:


result:

wrong output format Unexpected end of file - int32 expected

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%