QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#145420 | #4992. Enigmatic Enumeration | karuna# | WA | 3ms | 3896kb | C++17 | 1.1kb | 2023-08-22 12:01:37 | 2023-08-22 12:01:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3030;
int n, m;
vector<pair<int, int>> edges;
vector<int> g[MAXN];
int d[MAXN], par[MAXN], r[MAXN], c[MAXN];
long long cnt[2 * MAXN];
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v; cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
edges.push_back({u, v});
}
long long ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
d[j] = 1e9;
r[j] = 1e9;
}
queue<int> q;
q.push(i);
d[i] = 0;
while (!q.empty()) {
int v = q.front();
q.pop();
for (int x : g[v]) {
if (d[x] == 1e9) {
d[x] = d[v] + 1;
par[x] = v;
q.push(x);
}
}
}
for (auto [u, v] : edges) {
if (d[u] == 1e9) continue;
if (d[u] > d[v]) swap(u, v);
if (par[v] != u) {
c[v] += 1;
cnt[d[u] + d[v] + 1]++;
}
}
for (int i = 1; i <= n; i++) {
if (d[i] == 1e9) continue;
cnt[2 * d[i]] += c[i] * (c[i] - 1) / 2;
c[i] = 0;
}
}
for (int j = 1; j <= n; j++) {
if (cnt[j]) {
return !(cout << cnt[j] / j);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3656kb
input:
4 4 1 2 2 3 3 4 4 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
5 10 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5
output:
10
result:
ok single line: '10'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
6 6 1 2 2 3 3 1 4 5 5 6 6 4
output:
2
result:
ok single line: '2'
Test #4:
score: -100
Wrong Answer
time: 3ms
memory: 3896kb
input:
110 5995 109 20 100 23 99 65 106 40 105 62 89 67 57 9 83 38 38 20 28 11 39 28 32 20 108 90 96 50 97 51 80 40 64 48 101 27 84 27 43 35 103 79 70 32 29 28 109 2 43 16 110 94 101 71 84 67 23 19 33 17 107 79 90 33 83 64 57 39 105 46 47 1 80 79 93 67 78 53 34 20 105 15 77 66 65 63 102 57 76 59 47 40 95 4...
output:
11546370
result:
wrong answer 1st lines differ - expected: '215820', found: '11546370'