제출 #961715

#제출 시각아이디문제언어결과실행 시간메모리
961715danikoynov조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; const int maxn = 2010; int n, par[maxn], m; int find_leader(int v) { if (par[v] == v) return v; return (par[v] = find_leader(par[v])); } int ed[maxn][maxn]; void solve() { cin >> n >> m; for (int i = 1; i <= m; i ++) { int v, u; cin >> v >> u; ed[v][u] = 1; for (int y = 1; y <= n; y ++) for (int z = 1; z <= n; z ++) { if (!(ed[y][z] && ed[z][y])) continue; for (int w = 1; w <= n; w ++) { if (w == y || w== z) continue; if (ed[w][z] || ed[w][y]) { ed[w][z] = ed[w][y] = 1; } } } ll edges = 0; for (int x = 1; x <= n; x ++) for (int y = 1; y <= n; y ++) { //if (v == u && ed[v][u]) // cout << "v " << v << endl; edges += ed[x][y]; } cout << edges << endl; //for (int j = 1; j <= n; j ++) //cout << "sz " << j << " " << sz[j] << endl; } } int main() { solve(); return 0; } /** 6 7 1 2 2 3 3 4 4 5 5 6 6 5 5 4 5 9 3 1 5 1 3 4 5 2 1 2 5 4 3 5 2 4 1 3 2 5 4 5 4 3 4 2 2 3 3 2 5 3 2 1 1 5 4 1 1 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...