QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#648517 | #7679. Master of Both IV | ucup-team2526 | TL | 1ms | 5868kb | C++20 | 1.7kb | 2024-10-17 19:22:40 | 2024-10-17 19:22:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
std::cout << std::endl;
}
template<class T, class... Ts>
void err(T arg, Ts &... args) {
std::cout << fixed << setprecision(10) << arg << ' ';
err(args...);
}
const int mod = 998244353;
const int maxn = 2e5 + 5;
int vis[maxn];
struct LB {
int d[64];
void init() {
memset(d,0,sizeof(d));
}
bool insert (int x) {
for (int i = 62;i >= 0;i--) {
if ((x >> i) & 1) {
if (d[i]) x ^= d[i];
else {
d[i] = x;
break;
}
}
}
if (x == 0) return 0;
else return 1;
}
}lb[maxn];
int qmi(int a,int b) {
int res = 1;
while (b) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res % mod;
}
void GENSHEN_START() {
int n;cin >> n;
vector <int> a(n + 5);
for (int i = 0;i <= n;i++) lb[i].init();
for (int i = 0;i <= n;i++) vis[i] = 0;
for (int i = 1;i <= n;i++) cin >> a[i],vis[a[i]]++;
int cnt = 0,ans = 0;
for (int i = 1;i <= n;i++) {
//dbg(i,vis[i]);
if (!lb[0].insert(a[i])) {
cnt++;
}
}
//dbg(cnt);
ans = (qmi(2,cnt) - 1 + mod) % mod;
sort(a.begin() + 1,a.begin() + 1 + n);
vector<int>sum(n + 5);
for (int i = 1;i <= n;i++) {
for (int j = 1;i * j <= n;j++) {
if (!lb[i * j].insert(i)) {
sum[i * j] += vis[i];
}
else sum[i * j] += vis[i] - 1;
}
//dbg(i,sum);
if (vis[i]) ans = (ans + qmi(2,sum[i]) % mod) % mod;
}
cout << ans << '\n';
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) GENSHEN_START();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5868kb
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: -100
Time Limit Exceeded
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 ...