QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#648536#7679. Master of Both IVucup-team2526WA 1ms5724kbC++201.7kb2024-10-17 19:26:092024-10-17 19:26:10

Judging History

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

  • [2024-10-17 19:26:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5724kb
  • [2024-10-17 19:26:09]
  • 提交

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 (vis[i] && !lb[i * j].insert(i)) {
				sum[i * j] += vis[i];
			}
			else if (vis[i] && lb[i * j].insert(i)) 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: 0
Wrong Answer
time: 1ms
memory: 5724kb

input:

2
3
1 2 3
5
3 3 5 1 1

output:

4
6

result:

wrong answer 2nd numbers differ - expected: '11', found: '6'