QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#405411#8412. Desant 3 [B]james1BadCreeper0 13ms3620kbC++201.1kb2024-05-05 21:02:052024-05-05 21:02:06

Judging History

This is the latest submission verdict.

  • [2024-05-05 21:02:06]
  • Judged
  • Verdict: 0
  • Time: 13ms
  • Memory: 3620kb
  • [2024-05-05 21:02:05]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

int n, m; 
int a[1005], b[1005], ans[40], c[40]; 

void dfs(int x) {
    if (x > m) {
        int cnt = count(c + 1, c + n + 1, 1); 
        for (int i = 1; i <= n; ++i) {
            int res = 0; 
            for (int j = i; j <= n; ++j) {
                if (c[j] == 0) break; 
                if (c[j] == 1) ++res; 
                if (res == cnt) ans[j - i + 1] ^= 1; 
            }
        }
        return; 
    }
    if (c[a[x]] == -1 && c[b[x]] == -1) {
        c[a[x]] = 1; c[b[x]] = 1; 
        dfs(x + 1); 
        c[a[x]] = 0; c[b[x]] = 0; 
        dfs(x + 1); 
        c[a[x]] = -1, c[b[x]] = -1; 
    } else if (c[a[x]] == 1 || c[b[x]] == 0) { // 是否交换都一样
        swap(c[a[x]], c[b[x]]); 
        dfs(x + 1); 
        swap(c[a[x]], c[b[x]]); 
    } else dfs(x + 1); 
}

int main(void) {
    ios::sync_with_stdio(0); 
    cin >> n >> m; 
    for (int i = 1; i <= m; ++i) cin >> a[i] >> b[i], c[i] = -1; 
    dfs(1); 
    for (int i = 1; i <= n; ++i) cout << ans[i] << " \n"[i == n]; 
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

7 65
3 5
2 5
1 4
1 4
5 7
3 6
5 6
1 7
3 7
3 6
6 7
3 5
5 6
2 5
5 2
7 5
7 1
1 2
4 6
3 5
1 2
1 2
5 6
1 7
3 4
2 4
3 4
2 3
3 7
3 6
2 4
3 2
5 3
7 5
2 5
4 5
5 7
4 6
1 6
3 4
5 7
1 6
5 7
4 6
3 5
1 5
2 7
4 7
1 7
1 3
1 4
5 6
1 5
4 6
1 4
4 5
1 7
1 3
4 5
2 5
4 6
2 3
2 6
1 3
4 6

output:

-2 -2 -2 -2 -2 -2 -2

result:

wrong answer 1st lines differ - expected: '1 1 1 1 1 1 1', found: '-2 -2 -2 -2 -2 -2 -2'

Subtask #2:

score: 0
Wrong Answer

Test #20:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

input:

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

output:

-1 -2 -1 -2 -1 -1 -2 -1 -1 -2 -2 -1 -1 -1 -1

result:

wrong answer 1st lines differ - expected: '1 1 0 0 0 0 0 0 0 1 0 1 0 0 1', found: '-1 -2 -1 -2 -1 -1 -2 -1 -1 -2 -2 -1 -1 -1 -1'

Subtask #3:

score: 0
Wrong Answer

Test #37:

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

input:

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

output:

-2 -2 -1 -2 -2 -2 -2 -1 -1 -2 -1 -1 -2 -2 -2 -2 -1 -1 -1 -1

result:

wrong answer 1st lines differ - expected: '0 1 0 1 1 1 1 0 0 1 0 1 0 0 0 1 1 1 1 1', found: '-2 -2 -1 -2 -2 -2 -2 -1 -1 -2 -1 -1 -2 -2 -2 -2 -1 -1 -1 -1'

Subtask #4:

score: 0
Wrong Answer

Test #54:

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

input:

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

output:

-1 -2 -2 -2 -1 -2 -1 -1 -1 -1 -2 -1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1

result:

wrong answer 1st lines differ - expected: '0 1 1 1 1 0 0 0 0 0 1 1 0 1 0 1 0 1 0 1 1 1', found: '-1 -2 -2 -2 -1 -2 -1 -1 -1 -1 ...1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1'

Subtask #5:

score: 0
Wrong Answer

Test #73:

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

input:

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

output:

-1 -2 -2 -2 -2 -2 -1 -1 -2 -1 -2 -2 -2 -2 -2 -1 -2 -2 -2 -2 -2 -2 -2 -1

result:

wrong answer 1st lines differ - expected: '0 0 0 0 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 1 0 0 1 1', found: '-1 -2 -2 -2 -2 -2 -1 -1 -2 -1 ...2 -2 -1 -2 -2 -2 -2 -2 -2 -2 -1'

Subtask #6:

score: 0
Wrong Answer

Test #92:

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

input:

26 217
2 12
6 15
4 20
20 26
24 26
17 25
13 16
1 10
20 21
12 16
4 12
2 18
11 22
3 26
8 25
13 14
6 16
2 3
18 26
10 20
19 25
5 22
14 24
4 8
5 25
22 26
1 19
24 26
15 23
3 10
11 14
13 17
6 25
16 23
3 10
17 26
11 15
13 25
1 19
11 17
13 20
20 23
8 18
2 6
15 18
2 10
15 19
15 26
5 15
5 25
8 10
5 24
8 6
16 5
...

output:

-1 -2 -2 -1 -2 -2 -2 -1 -2 -1 -2 -1 -2 -1 -2 -1 -1 -2 -2 -2 -2 -1 -2 -2 -2 -1

result:

wrong answer 1st lines differ - expected: '0 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 0 1 1 0 1 1', found: '-1 -2 -2 -1 -2 -2 -2 -1 -2 -1 ...1 -1 -2 -2 -2 -2 -1 -2 -2 -2 -1'

Subtask #7:

score: 0
Wrong Answer

Test #111:

score: 0
Wrong Answer
time: 3ms
memory: 3564kb

input:

29 241
6 27
21 27
2 28
8 12
17 25
19 20
6 25
14 27
8 22
2 24
3 25
8 27
13 24
15 21
7 13
8 9
6 15
12 14
2 25
20 23
1 2
16 23
10 17
9 12
9 26
19 21
12 22
12 18
9 18
7 22
8 23
4 25
8 27
10 17
9 27
15 21
19 22
7 11
4 6
14 26
16 20
2 11
4 25
15 19
16 23
23 26
4 7
6 12
18 20
11 17
1 12
1 12
11 25
3 28
20 ...

output:

-1 -1 -2 -2 -2 -1 -1 -2 -1 -2 -1 -2 -2 -1 -1 -1 -1 -2 -2 -2 -1 -1 -2 -2 -1 -1 -1 -1 -1

result:

wrong answer 1st lines differ - expected: '1 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1', found: '-1 -1 -2 -2 -2 -1 -1 -2 -1 -2 ...2 -2 -1 -1 -2 -2 -1 -1 -1 -1 -1'

Subtask #8:

score: 0
Wrong Answer

Test #130:

score: 0
Wrong Answer
time: 4ms
memory: 3604kb

input:

32 265
14 24
25 32
5 19
3 6
2 9
5 29
3 22
5 19
7 8
19 28
14 27
7 20
1 14
7 12
12 20
6 22
1 32
16 26
1 6
20 23
12 21
16 19
3 23
4 20
8 30
11 12
26 28
9 14
13 32
18 25
21 27
1 9
10 12
10 16
5 16
4 13
3 11
17 25
8 28
3 32
24 25
19 24
6 12
21 31
2 27
25 31
1 31
6 24
11 24
14 19
8 11
12 28
9 21
20 27
5 2...

output:

-2 -2 -2 -2 -1 -1 -2 -1 -1 -1 -2 -2 -1 -2 -1 -1 -2 -1 -2 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

result:

wrong answer 1st lines differ - expected: '0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 1 0 1 0 0 1', found: '-2 -2 -2 -2 -1 -1 -2 -1 -1 -1 ...1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1'

Subtask #9:

score: 0
Wrong Answer

Test #149:

score: 0
Wrong Answer
time: 7ms
memory: 3596kb

input:

34 281
13 16
14 22
2 29
2 13
14 31
1 33
15 29
2 31
25 29
4 5
10 12
10 13
16 29
19 31
9 19
4 22
6 12
19 21
6 16
3 13
5 22
7 17
22 28
6 33
5 16
14 34
1 15
13 22
25 28
3 21
9 10
1 8
23 28
8 10
8 12
2 16
10 20
25 27
27 34
13 34
6 21
10 32
19 25
1 10
13 29
18 31
8 33
20 34
7 8
10 23
10 30
10 15
17 21
4 3...

output:

-1 -1 -1 -1 -2 -2 -1 -1 -2 -1 -2 -2 -2 -1 -1 -2 -2 -2 -1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

result:

wrong answer 1st lines differ - expected: '0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 ...0 0 0 0 0 1 0 0 1 1 1 1 0 1 1 1', found: '-1 -1 -1 -1 -2 -2 -1 -1 -2 -1 ...1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1'

Subtask #10:

score: 0
Wrong Answer

Test #168:

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

input:

35 289
15 29
8 17
4 15
6 17
4 35
13 33
11 17
11 19
8 33
3 34
14 22
3 7
4 8
2 11
8 30
24 33
18 23
20 25
11 18
11 12
19 29
4 25
16 32
10 33
14 16
1 12
11 13
13 30
16 29
15 32
11 18
26 27
14 30
12 21
11 13
2 34
4 21
29 35
19 35
10 27
28 35
3 16
2 23
30 34
6 14
7 16
18 30
11 23
6 33
12 15
1 22
12 34
18 ...

output:

-1 -2 -2 -2 -1 -1 -2 -2 -2 -2 -1 -1 -1 -1 -2 -1 -1 -1 -1 -2 -2 -2 -1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

result:

wrong answer 1st lines differ - expected: '1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 ...1 1 0 1 0 1 0 1 0 0 1 1 0 1 1 1', found: '-1 -2 -2 -2 -1 -1 -2 -2 -2 -2 ...1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1'