QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#252904 | #7679. Master of Both IV | ucup-team1321# | WA | 76ms | 25968kb | C++23 | 2.4kb | 2023-11-16 14:40:50 | 2023-11-16 14:40:51 |
Judging History
answer
#include <bits/stdc++.h>
#ifndef LOCAL
#define debug(...) 42
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif
#define rep1(a) for (int i = 0; i < a; i++)
#define rep2(i, a) for (int i = 0; i < a; i++)
#define rep3(i, a, b) for (int i = a; i < b; i++)
#define rep4(i, a, b, c) for (int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define pb emplace_back
using namespace std;
template <typename T, typename T2> void cmin(T &x, const T2 &y) {
x = x < y ? x : y;
}
template <typename T, typename T2> void cmax(T &x, const T2 &y) {
x = x > y ? x : y;
}
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
template <class T> using vc = vector<T>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
mt19937 rng(time(NULL));
const int inf = 1000000000;
const ll lnf = 1000000000000000000;
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
const int P = 998244353;
vi d[200005];
int pw[200005];
int p[33];
void solve() {
int n;
cin >> n;
vi a(n);
vi c(n + 1);
rep(i, n) cin >> a[i], ++c[a[i]];
ll ans = 0;
for (int i = 1; i <= n; i++) {
if (c[i] == 0) continue;
int coef = pw[c[i] - 1];
for (int j : d[i]) {
if (c[j] < 2) continue;
coef = 1ll * coef * pw[c[j] - 1] % P;
}
ans += coef;
if (ans >= P) {
ans -= P;
}
}
for (int i = 0; i < 30; i++) p[i] = 0;
rep(i, n) {
int x = a[i];
for (int j = 29; j >= 0; j--) {
if (x >> j & 1) {
if (!p[j]) {
p[j] = x;
break;
}
x ^= p[j];
}
}
}
int cnt = 0;
for (int i = 0; i < 30; i++) {
if (p[i]) {
cnt += 1;
}
}
ans += pw[n - cnt] - 1;
if (ans >= P) {
ans -= P;
}
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
for (int i = 1; i < 200005; i++) {
for (int j = i * 2; j < 200005; j += i) {
d[j].pb(i);
}
}
pw[0] = 1;
for (int i = 1; i < 200005; i++) {
pw[i] = pw[i - 1] + pw[i - 1];
if (pw[i] >= P) {
pw[i] -= P;
}
}
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 62ms
memory: 25804kb
input:
2 3 1 2 3 5 3 3 5 1 1
output:
4 11
result:
ok 2 number(s): "4 11"
Test #2:
score: 0
Accepted
time: 76ms
memory: 25836kb
input:
40000 5 4 2 5 5 5 5 5 5 5 5 4 5 1 4 4 4 2 5 2 5 2 4 1 5 3 2 4 5 3 5 1 5 5 3 4 5 5 5 5 4 3 5 4 3 3 5 1 5 4 5 5 2 1 5 2 5 4 2 5 5 3 4 3 4 3 5 5 3 5 1 3 5 5 1 2 4 4 5 4 2 5 1 5 5 5 4 2 5 4 5 5 2 5 2 4 5 1 4 5 4 5 5 4 2 3 2 3 5 1 4 1 3 5 5 1 1 2 1 5 5 5 2 5 1 3 5 3 1 2 5 3 5 5 5 1 1 5 5 2 2 2 1 3 5 3 1 ...
output:
9 16 9 9 8 8 9 8 8 9 13 8 8 8 8 9 12 9 11 15 8 8 17 13 8 11 8 8 8 13 15 9 9 8 8 8 11 9 11 13 15 9 17 9 8 8 8 13 11 8 9 11 8 8 11 15 9 8 9 8 8 15 11 8 17 9 15 8 8 8 12 9 9 11 8 13 9 8 15 8 8 9 8 8 8 15 8 11 13 8 9 11 8 19 11 13 19 17 13 15 8 8 8 9 8 9 13 15 17 9 9 17 9 11 9 9 11 9 9 11 8 9 9 13 15 11...
result:
ok 40000 numbers
Test #3:
score: -100
Wrong Answer
time: 64ms
memory: 25968kb
input:
20000 10 1 3 6 8 3 1 10 7 2 3 10 8 2 8 9 10 5 8 4 8 3 10 2 2 10 1 6 4 4 3 4 7 10 6 5 10 7 8 7 3 1 6 6 10 3 2 3 7 8 4 9 8 8 7 10 9 9 6 4 9 3 9 10 5 9 10 10 8 9 10 10 4 5 1 4 3 10 2 10 4 5 8 10 2 2 7 2 10 2 6 4 10 1 1 1 1 2 3 10 1 10 2 8 1 5 9 4 3 1 10 8 1 8 1 9 5 6 7 2 9 10 1 6 7 4 8 8 7 3 5 7 10 10 ...
output:
89 77 80 74 75 84 75 105 143 95 81 74 78 73 73 73 83 93 90 84 79 77 73 89 77 73 81 79 80 175 83 77 83 76 83 85 84 97 74 80 101 74 113 74 75 95 75 83 86 77 99 73 77 83 91 96 77 80 77 76 80 81 73 95 83 74 75 81 77 79 74 76 78 81 97 77 85 73 92 83 73 80 73 77 74 73 142 83 99 78 91 77 76 81 77 74 78 76 ...
result:
wrong answer 1st numbers differ - expected: '97', found: '89'