QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#711266#4782. 完美的旅行NineSuns0 0ms3744kbC++141.8kb2024-11-05 08:32:062024-11-05 08:32:07

Judging History

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

  • [2024-11-05 08:32:07]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3744kb
  • [2024-11-05 08:32:06]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back

using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 64, M = 10005, mod = 998244353; 
int n, m, a[N][N], ans[N][M]; 
struct mat {
	int a[N][N]; 
	void clr () { for (int i = 0;i < n;i++) memset(a[i], 0, n<<2); }
	void init () {
		clr(); 
		for (int i = 0;i < n;i++) a[i][i] = 1; 
	}
	friend mat operator * (const mat & a, const mat & b) {
		mat c; c.clr(); 
		for (int i = 0;i < n;i++) {
			for (int j = 0;j < n;j++) {
				for (int z = 0;z < n;z++) (c.a[i][j] += (1ll*a.a[i][z]*b.a[z][j]%mod)) %= mod; 
			}
		}
		return c; 
	}
};

void solve () {
	cin >> n >> m; 
	for (int i = 0;i < n;i++) for (int j = 0;j < n;j++) cin >> a[i][j]; 
	int V = 0;
	for (int i = n-1;i >= 0;i--) {
		vector <int> td; 
		for (int j = 0;j < n;j++) {
			if ((i&j) == i) td.pb(j); 
		}
		mat d; d.clr(); 
		for (int j = 0;j < n;j++) {
			for (int z = 0;z < n;z++) d.a[j][z] = a[j][z];  
		}
		mat res; res.init(); 
		for (int j = 1;j <= m;j++) {
			res = res*d; 
			for (int x : td) {
				for (int y : td) (ans[i][j] += res.a[x][y]) %= mod;  
			}
			for (int x : td) (res.a[x][x] += ans[i][j]) %= mod; 
		}
		for (int j = i+1;j < n;j++) {
			if ((j&i)^i) continue; 
			for (int z = 1;z <= m;z++) {
				int o = __builtin_popcount(j^i); 
				if (o&1) ans[i][z] -= ans[j][z]; else ans[i][z] += ans[j][z]; 
				ans[i][z] %= mod; 
			}
		}
		for (int z = 1;z <= m;z++) {
			ans[i][z] = (ans[i][z]+mod)%mod; 
//			cout << i << " " << z << " " << ans[i][z] << endl; 
			V ^= ans[i][z]; 
		}
	}
	cout << V; 
}

signed main () {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int T = 1;
	while (T--) solve();
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3744kb

input:

4 20
53674686 128460215 363694167 120271218
578912024 941426068 993595265 587468617
731649477 694107878 355552389 226535630
99325151 243772822 66420647 578481511

output:

1007247455

result:

wrong answer 1st numbers differ - expected: '588479706', found: '1007247455'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Time Limit Exceeded

Test #21:

score: 0
Time Limit Exceeded

input:

16 20000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 14
2 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13
3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12
4 5 6 7 0 1 2 3 12 13 14 15 8 9 10 11
5 4 7 6 1 0 3 2 13 12 15 14 9 8 11 10
6 7 4 5 2 3 0 1 14 15 12 13 10 11 8 9
7 6 5 4 3 2 1 0 15 14 13 ...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%