# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
49203 | BThero | Duathlon (APIO18_duathlon) | C++17 | 5 ms | 1088 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Why am I so stupid? :c
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
typedef long long ll;
using namespace std;
vector <int> adj[105];
bool can[105];
bool u[105];
int n, m;
int ans;
void dfs(int v, int fn) {
if (v == fn) {
for (int i = 1; i <= n; ++i) {
can[i] |= u[i];
}
return;
}
u[v] = 1;
for (int to : adj[v]) {
if (u[to]) {
continue;
}
dfs(to, fn);
}
u[v] = 0;
}
void solve() {
scanf("%d %d", &n, &m);
for (int i = 1, u, v; i <= m; ++i) {
scanf("%d %d", &u, &v);
adj[u].pb(v);
adj[v].pb(u);
}
for (int a = 1; a <= n; ++a) {
for (int b = 1; b <= n; ++b) {
if (a == b) {
continue;
}
dfs(a, b);
for (int i = 1; i <= n; ++i) {
ans += can[i];
can[i] = 0;
}
--ans;
}
}
printf("%d\n", ans);
}
int main() {
#ifdef BThero
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // BThero
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |