QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#649207 | #5407. 基础图论练习题 | londono | 0 | 0ms | 0kb | C++14 | 3.1kb | 2024-10-17 22:04:59 | 2024-10-17 22:05:00 |
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1505;
const int mod = (int)1e9+7;
int qkpow(int x, int y) {
int res = 1;
while (y) {
if (y & 1) res = (ll)res * x % mod;
x = (ll)x * x % mod; y >>= 1;
}
return res;
}
struct mint{
int x; mint() { x = 0; } mint(ll _x) { x = (_x%mod+mod)%mod; }
mint operator + (mint y) { return mint(x + y.x); }
mint operator - (mint y) { return mint(x - y.x); }
mint operator * (mint y) { return mint((ll)x * y.x % mod); }
mint operator / (mint y) { return mint((ll)x * qkpow(y.x,mod-2) % mod); }
mint operator += (mint y) { return (*this) = (*this) + y; }
mint operator -= (mint y) { return (*this) = (*this) - y; }
mint operator *= (mint y) { return (*this) = (*this) * y; }
mint operator /= (mint y) { return (*this) = (*this) / y; }
}pw[MAXN];
int T, n, deg[MAXN];
int p1[MAXN], n1[MAXN], ok[MAXN];
bitset<MAXN> G[MAXN];
int di[MAXN];
int calc() {
memcpy(di, deg, sizeof deg);
sort(di+1, di+n+1);
int res = 0;
for (int i = 1; i <= n; i++) {
di[i] += di[i-1];
if (di[i] == i*(i-1)/2) res ++;
}
return res;
}
int main() {
// g++ code.cpp -o code.exe -std=c++14 -O2 -fno-ms-extensions -DLOCAL; ./code
time_t st = clock();
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("ans.out", "w", stdout);
#else
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio();
cin.tie(0), cout.tie(0);
#endif
pw[0] = 1;
for (int i = 1; i < MAXN; i++) {
pw[i] = pw[i-1] * 2;
}
cin >> T; while (T--) {
cin >> n;
for (int i = 2; i <= n; i++) {
string s; cin >> s;
for (int j = 0; j < s.size(); j++) {
int e;
if (isalpha(s[j])) e = s[j]-'A'+10;
if (isdigit(s[j])) e = s[j]-'0';
for (int k = 0, to; k < 4; k++) {
to = j*4+k+1;
if (to >= i) break;
if ((1<<k)&e) G[i][to] = 1, deg[i]++;
else G[to][i] = 1, deg[to]++;
}
}
}
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= n; j++) {
// printf("%d ", (int)G[i][j]);
// } puts("");
// }
mint ans;
for (int i = 1; i <= n; i++) {
for (int j = i-1; j >= 1; j--) {
if (G[i][j]) deg[i]--, deg[j]++;
if (G[j][i]) deg[j]--, deg[i]++;
ans += pw[(i-2)*(i-1)/2+j-1]*calc();
if (G[i][j]) deg[i]++, deg[j]--;
if (G[j][i]) deg[j]++, deg[i]--;
}
}
cout << ans.x << '\n';
break;
for (int i = 1; i <= n; i++) {
deg[i] = 0;
for (int j = 1; j <= n; j++) {
G[i][j] = 0;
}
}
}
cerr << "Exec Time:" << (double)(clock()-st)/CLOCKS_PER_SEC << "s" << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
10000 100 1 2 2 8 C0 F0 27 78 AE1 C01 511 D87 EF20 3873 2742 73D0 DC9B0 FB2A3 9C011 9B4E0 95DC00 A7B980 F43531 6A6245 5347BE0 1A6C8A1 88E46D6 64CF3AE D25F63C1 C894E4C3 1C0AFD73 EC1C3F9A 087CE17C0 22149A380 B28038AF1 B9CA21C7F D78F5307C1 49045489A2 72C4DE6FD1 7713F40D05 EEE8878EEC1 310E62812B1 DA9D5B...
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%