QOJ.ac
QOJ
QOJ is currently under a maintenance. It might be unavailable in the following a few hours.
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#959258 | #6865. foreverlasting and fried-chicken | Da_Capo | AC ✓ | 97ms | 3840kb | C++20 | 2.8kb | 2025-03-31 17:08:39 | 2025-03-31 17:08:44 |
Judging History
answer
// #include <algorithm>
// #include <bitset>
// #include <cctype>
// #include <cerrno>
// #include <clocale>
// #include <cmath>
// #include <complex>
// #include <cstdio>
// #include <cstdlib>
// #include <cstring>
// #include <ctime>
// #include <deque>
// #include <exception>
// #include <fstream>
// #include <functional>
// #include <limits>
// #include <list>
// #include <map>
// #include <iomanip>
// #include <ios>
// #include <iosfwd>
// #include <iostream>
// #include <istream>
// #include <ostream>
// #include <queue>
// #include <set>
// #include <sstream>
// #include <stack>
// #include <stdexcept>
// #include <streambuf>
// #include <string>
// #include <utility>
// #include <vector>
// #include <cwchar>
// #include <cwctype>
#include <bits/stdc++.h>
#define int long long
// #define int __int128
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define lowbit(x) ((x) & (-x))
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, string> PIS;
typedef pair<ld, int> PDI;
const int N = 1e3 + 10, M = 1e3 + 10, INF = 1e18;
const double eps = 1e-15;
const int mod = 1e9 + 7;
// int mod = 1e9 + 7;
int n, m, k;
int dx[4] = {1, 0, 0, -1}, dy[4] = {0, -1, 1, 0};
int a[N], b[N], c[N];
// int a, b, c;
// double a, b, c;
char op;
int x, y, z, r;
// double x, y, z, r;
string s, s1, s2, str;
// vector<PII> v[N];
int f[N];
bitset<N> adj[N];
int d[N];
int c4(int x)
{
return (x * (x - 1) * (x - 2) * (x - 3) / 24) % mod;
}
int c2(int x)
{
return (x * (x - 1) / 2) % mod;
}
void solve(int _)
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
adj[i].reset();
d[i] = 0;
}
for (int i = 0; i < m; i++)
{
cin >> x >> y;
d[x]++, d[y]++;
adj[x].set(y);
adj[y].set(x);
}
int res = 0;
for (int i = 1; i <= n; i++)
{
for (int j = i + 1; j <= n; j++)
{
int s = (adj[i] & adj[j]).count();
int sa = d[i], sb = d[j];
if (adj[i].test(j)) // 去掉他们相邻的边
sa--, sb--;
if (s < 4)
continue;
res = (res + c4(s) * c2(sa - 4) % mod) % mod;
res = (res + c4(s) * c2(sb - 4) % mod) % mod;
}
}
cout << res << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// getp(1000000);
int t = 1;
cin >> t;
cout << fixed << setprecision(12);
// getline(cin, s);
// while (t--)
for (int i = 1; i <= t; i++)
{
solve(i);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 97ms
memory: 3840kb
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 4 37800 0 278229818 23929419 3268272
result:
ok 9 lines