QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#130558 | #1944. Circle of Friends | karuna# | WA | 1ms | 9616kb | C++17 | 1.3kb | 2023-07-24 16:05:10 | 2023-07-24 16:05:13 |
Judging History
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'