QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#130558#1944. Circle of Friendskaruna#WA 1ms9616kbC++171.3kb2023-07-24 16:05:102023-07-24 16:05:13

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-24 16:05:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9616kb
  • [2023-07-24 16:05:10]
  • 提交

answer

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

typedef long long ll;

const int MAXN = 202020;
const ll MOD = 998244353;

int n; ll a[2 * MAXN], s[20][2 * MAXN], dp[2 * MAXN];
int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[n + i] = a[i];
    }
    for (int i = 1; i <= 2 * n; i++) {
        s[0][i] = a[i];
    }
    for (int j = 1; j < 20; j++) {
        for (int i = (1 << j); i <= 2 * n; i++)
            s[j][i] = s[j - 1][i] & s[j - 1][i - (1 << (j - 1))];
    }
    ll ans = 0;
    for (int r = n + 1; r >= 1; ) {
        dp[r - 1] = 1;
        for (int i = r; i <= n; i++) dp[i] = 1;
        for (int i = n + 1; i <= 2 * n; i++) {
            ll x = a[i];
            int p = i;
            for (int j = 19; j >= 0; j--) {
                if ((x & s[j][p]) != 0) {
                    x = x & s[j][p];
                    p = p - (1 << j);
                }
                dp[i] = (dp[i - 1] + dp[i - 1]) % MOD;
                if (p != 0)
                    dp[i] = (dp[i] + MOD - dp[p - 1]) % MOD;
            }
        }
        int l = r;
        while (l >= 1 && (a[l] & a[r]) == a[r]) --l;

        ans += (dp[n + r - 1] - dp[n + l - 1] + MOD) % MOD;
        r = l;
    }
    cout << ans << '\n';
}

详细

Test #1:

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

input:

1
1

output:

2

result:

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