QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#153262#6865. foreverlasting and fried-chickenneko_nyaaWA 484ms3648kbC++231.0kb2023-08-29 19:39:022023-08-29 19:39:03

Judging History

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

  • [2023-08-29 19:39:03]
  • 评测
  • 测评结果:WA
  • 用时:484ms
  • 内存:3648kb
  • [2023-08-29 19:39:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int M = 1000000007;
int modpow(int n, int k) {
	int ans = 1;
	while (k) {
		if (k % 2) ans = (ans*n) % M;
		n = (n*n) % M; k /= 2;
	}
	return ans;
}

int c4(int n) {
	int p = n*(n-1)*(n-2)*(n-3);
	int q = 1*2*3*4;
	return p*modpow(q, M-2) % M;
}

int c2(int n) {
	int p = n*(n-1);
	int q = 1*2;
	return p*modpow(q, M-2) % M;
}

typedef bitset<1000> bs;

void solve() {
	int n, m; cin >> n >> m;
	vector<bs> adj(n);

	while (m--) {
		int x, y; cin >> x >> y; x--, y--;
		adj[x][y] = adj[y][x] = 1;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) continue;

			int up = adj[i].count();
			int down = (adj[i] & adj[j]).count();

			if (up < 6 || down < 4) continue;
			int tmp = c4(down);
			tmp = (tmp*c2(up-4)) % M;

			ans = (ans+tmp) % M;
		}
	}
	cout << ans << '\n';
}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);

	int t; cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 484ms
memory: 3648kb

input:

9
8 10
1 2
1 3
1 4
1 5
1 6
1 7
8 4
8 5
8 6
8 7
10 12
1 2
1 3
1 4
1 5
1 6
1 7
8 4
8 5
8 6
8 7
8 9
8 10
11 13
1 2
1 3
1 4
1 5
1 6
1 7
8 4
8 5
8 6
8 7
8 9
8 10
1 11
11 14
1 2
1 3
1 4
1 5
1 6
1 7
8 4
8 5
8 6
8 7
8 9
8 10
1 11
1 8
10 45
5 10
2 9
5 8
3 10
2 10
4 9
4 3
4 2
5 6
7 1
10 6
10 7
6 1
8 3
5 1
7 5...

output:

1
2
4
9
63000
0
624414727
755929618
4088223

result:

wrong answer 4th lines differ - expected: '4', found: '9'