이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
int n, m;
vector<int> g[N];
bool vis[N], possible[N][N][N];
void dfs(int v, int y, int z){
if (v == z) return;
vis[v] = 1;
for (int u : g[v])
if (!vis[u]) dfs(u, y, z);
}
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 total = n * (n - 1) * (n - 2);
for (int u = 1; u <= n; u ++){
for (int v = 1; v <= n; v ++){
for (int e = 1; e <= n; e ++){
memset(vis, 0, sizeof vis);
dfs(u, v, e);
if (vis[v])
possible[u][v][e] = 1;
}
}
}
for (int c = 1; c <= n; c ++){
for (int s = 1; s <= n; s ++){
for (int f = 1; f <= n; f ++){
if (c == s or c == f or s == f) continue;
bool bad = 0;
for (int v = 1; v <= n; v ++){
if (v == c) continue;
if (!possible[s][c][v] and !possible[c][f][v])
bad = 1;
}
total -= bad;
}
}
}
cout << total << endl;
}
# | 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... |