이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n, m;
vector<int> g[N];
bool vis[N];
void dfs(int v){
if (vis[v]) return;
vis[v] = 1;
for (int u : g[v])
if (!vis[u])
dfs(u);
}
int main(){
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);
}
int ans = 0;
for (int s = 1; s <= n; s ++){
for (int c = 1; c <= n; c ++){
for (int f = 1; f <= n; f ++){
if (s == c or s == f or c == f) continue;
bool good = 1;
for (int e = 1; e <= n; e ++){
if (e == c) continue;
memset(vis, 0, sizeof vis);
vis[e] = 1;
dfs(s);
if (vis[c]) continue;
vis[e] = 1;
dfs(f);
if (vis[c]) continue;
good = 0;
break;
}
ans += good;
}
}
}
cout << ans << endl;
}
/*
There is some vertex mid i.e every path from c to f and c to s goes through it.
if there is no such vertex then (s, c, f) is a valid tuple.
*/
# | 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... |