QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#273156#7886. Not Another Eulerian Number ProblemSulfox#AC ✓44ms3956kbC++201.1kb2023-12-02 21:40:482023-12-02 21:40:49

Judging History

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

  • [2023-12-02 21:40:49]
  • 评测
  • 测评结果:AC
  • 用时:44ms
  • 内存:3956kb
  • [2023-12-02 21:40:48]
  • 提交

answer

#include <bits/stdc++.h>

const int N = 12;

int k, n, m, n0, a[N], b[N];

bool iscnt() {
    int cnt = 0;
    for (int i = 1; i < k * n; i++) {
        cnt += b[i - 1] > b[i];
    }
    return cnt == m;
}
bool isper() {
    for (int i = 0; i < k * n; i++) {
        bool has = false;
        for (int j = i - 1; j >= 0; j--) {
            if (b[j] == b[i]) { has = true; break; }
        }
        if (has) {
        for (int j = i - 1; j >= 0; j--) {
            if (b[j] == b[i]) { break; }
            if (b[j] < b[i]) { return false; }
        }
        }
    }
    return true;
}

int main() {
    scanf("%d%d%d%d", &k, &n, &m, &n0);
    for (int i = 0; i < k * n0; i++) { scanf("%d", &a[i]); }
    for (int i = 0; i < k * n; i++) { b[i] = i / k + 1; }
    int ans = 0;
    do {
        bool ok = true;
        for (int i = 0, j = 0; i < k * n; i++) {
            if (b[i] <= n0) {
                if (b[i] != a[j]) { ok = false; break; }
                j++;
            }
        }
        ans += ok && iscnt() && isper();
    } while (std::next_permutation(b, b + k * n));
    printf("%d\n", ans);
    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3912kb

input:

1 4 2 2
2 1

output:

7

result:

ok 1 number(s): "7"

Test #2:

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

input:

2 4 2 2
1 2 2 1

output:

19

result:

ok 1 number(s): "19"

Test #3:

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

input:

1 1 0 1
1

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

3 1 0 1
1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

4 1 0 1
1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #6:

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

input:

5 1 0 1
1 1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

10 1 0 1
1 1 1 1 1 1 1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #8:

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

input:

1 3 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

input:

3 3 2 3
2 2 2 3 3 3 1 1 1

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

3 3 2 2
1 1 2 2 2 1

output:

5

result:

ok 1 number(s): "5"

Test #11:

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

input:

3 3 2 1
1 1 1

output:

15

result:

ok 1 number(s): "15"

Test #12:

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

input:

3 3 1 2
2 2 2 1 1 1

output:

2

result:

ok 1 number(s): "2"

Test #13:

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

input:

1 4 0 4
4 2 1 3

output:

0

result:

ok 1 number(s): "0"

Test #14:

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

input:

2 4 1 4
1 4 4 3 3 2 2 1

output:

0

result:

ok 1 number(s): "0"

Test #15:

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

input:

2 4 2 4
1 3 3 2 2 4 4 1

output:

1

result:

ok 1 number(s): "1"

Test #16:

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

input:

2 4 2 1
1 1

output:

58

result:

ok 1 number(s): "58"

Test #17:

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

input:

2 4 1 2
1 1 2 2

output:

14

result:

ok 1 number(s): "14"

Test #18:

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

input:

1 8 7 3
2 1 3

output:

0

result:

ok 1 number(s): "0"

Test #19:

score: 0
Accepted
time: 1ms
memory: 3892kb

input:

1 8 0 4
1 2 3 4

output:

1

result:

ok 1 number(s): "1"

Test #20:

score: 0
Accepted
time: 1ms
memory: 3856kb

input:

1 8 4 4
4 3 1 2

output:

771

result:

ok 1 number(s): "771"

Test #21:

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

input:

1 8 1 4
4 3 2 1

output:

0

result:

ok 1 number(s): "0"

Test #22:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

1 8 7 1
1

output:

1

result:

ok 1 number(s): "1"

Test #23:

score: 0
Accepted
time: 2ms
memory: 3888kb

input:

1 9 2 5
4 3 1 5 2

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 2ms
memory: 3904kb

input:

1 9 7 8
6 5 8 3 4 7 2 1

output:

0

result:

ok 1 number(s): "0"

Test #25:

score: 0
Accepted
time: 2ms
memory: 3828kb

input:

1 9 7 7
5 3 2 4 7 6 1

output:

0

result:

ok 1 number(s): "0"

Test #26:

score: 0
Accepted
time: 2ms
memory: 3828kb

input:

1 9 7 6
2 1 3 5 6 4

output:

0

result:

ok 1 number(s): "0"

Test #27:

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

input:

1 9 3 3
1 2 3

output:

20420

result:

ok 1 number(s): "20420"

Test #28:

score: 0
Accepted
time: 13ms
memory: 3904kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #29:

score: 0
Accepted
time: 32ms
memory: 3844kb

input:

1 10 7 2
2 1

output:

30973

result:

ok 1 number(s): "30973"

Test #30:

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

input:

1 10 1 6
6 3 5 2 4 1

output:

0

result:

ok 1 number(s): "0"

Test #31:

score: 0
Accepted
time: 43ms
memory: 3772kb

input:

1 10 2 1
1

output:

47840

result:

ok 1 number(s): "47840"

Test #32:

score: 0
Accepted
time: 44ms
memory: 3820kb

input:

1 10 5 2
2 1

output:

689155

result:

ok 1 number(s): "689155"

Extra Test:

score: 0
Extra Test Passed