QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#153266#6865. foreverlasting and fried-chickenneko_nyaaWA 488ms3524kbC++231.1kb2023-08-29 19:42:062023-08-29 19:42:07

Judging History

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

  • [2023-08-29 19:42:07]
  • 评测
  • 测评结果:WA
  • 用时:488ms
  • 内存:3524kb
  • [2023-08-29 19:42:06]
  • 提交

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 (adj[i][j]) {
				up--; down--;
			}

			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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 488ms
memory: 3524kb

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
0
18900
0
864788514
444114113
2243332

result:

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