QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#715926#7303. City UnitedDifficult_to_namingWA 95ms69956kbC++141.3kb2024-11-06 13:49:062024-11-06 13:49:07

Judging History

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

  • [2024-11-06 13:49:07]
  • 评测
  • 测评结果:WA
  • 用时:95ms
  • 内存:69956kb
  • [2024-11-06 13:49:06]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
const int mod = 1594323;
int n, m, u, v, Vec[102], pow3[20], f[2000003][2], dp[50][2000003], ans;
std::vector<int> vec[103];
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), vec[u].push_back(v), vec[v].push_back(u);
        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][1] & Vec[i]))
                dp[i][j * 3 % mod + 2] =
                    (dp[i][j * 3 % mod + 2] + dp[i - 1][j]) % 4;
            if (!(f[j][2] & 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 90ms
memory: 67784kb

input:

3 2
1 2
2 3

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: -100
Wrong Answer
time: 95ms
memory: 69956kb

input:

3 3
1 2
2 3
3 1

output:

0

result:

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