QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#715979#7303. City UnitedDifficult_to_namingWA 59ms17968kbC++141.2kb2024-11-06 13:58:442024-11-06 13:58:46

Judging History

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

  • [2024-11-06 13:58:46]
  • 评测
  • 测评结果:WA
  • 用时:59ms
  • 内存:17968kb
  • [2024-11-06 13:58:44]
  • 提交

answer

#include <bits/stdc++.h>
const int mod = 1594323;
int n, m, u, v, Vec[102], pow3[20], f[1594324][2], dp[51][1594324], ans;
void init() {
    pow3[0] = 1, dp[0][0] = 1;
    for (int i = 1; i < 20; i++)
        pow3[i] = pow3[i - 1] * 3;
    for (int i = 0; i < mod; i++)
        for (int j = 0; j < 13; j++) {
            int nw = i / pow3[j] % 3;
            if (nw)
                f[i][nw - 1] |= (1 << j);
        }
}
signed main() {
    scanf("%lld%lld", &n, &m), init();
    for (; m--;) {
        scanf("%lld%lld", &u, &v);
        if (u > v)
            std::swap(u, v);
        Vec[v] |= (1 << v - u - 1);
    }
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < mod; j++) {
            dp[i][j * 3 % mod] = (dp[i][j * 3 % mod] + dp[i - 1][j]) % 4;
            if (!(f[j][0] & Vec[i]))
                dp[i][j * 3 % mod + 2] =
                    (dp[i][j * 3 % mod + 2] + dp[i - 1][j]) % 4;
            if (!(f[j][1] & Vec[i]))
                dp[i][j * 3 % mod + 1] =
                    (dp[i][j * 3 % mod + 1] + dp[i - 1][j]) % 4;
        }
    for (int i = 0; i < mod; i++)
        ans = (ans + dp[n][i]) % 4;
    printf("%lld", ans / 2);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 59ms
memory: 17968kb

input:

3 2
1 2
2 3

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: -100
Wrong Answer
time: 55ms
memory: 17684kb

input:

3 3
1 2
2 3
3 1

output:

0

result:

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