Submission #430883

#TimeUsernameProblemLanguageResultExecution timeMemory
430883Kevin_Zhang_TWMaking Friends on Joitter is Fun (JOI20_joitter2)C++17
1 / 100
2959 ms588 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define pb emplace_back #define AI(i) begin(i), end(i) template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); } template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); } #ifdef KEV #define DE(args...) kout("[ " + string(#args) + " ] = ", args) void kout() { cerr << endl; } template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); } template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; } #else #define DE(...) 0 #define debug(...) 0 #endif // My bug list : // integer overflow // 0based, 1based forgotten // index out of bound // n, m, i, j typo // some cases are missing const int MAX_N = 55; int n, m; int con[MAX_N][MAX_N], g[MAX_N]; int F(int i) { return i == g[i] ? i : g[i] = F(g[i]) ; } ll ans; void add_edge(int a, int b) { if (con[a][b]) return; con[a][b] = true; ++ans; for (int i = 1;i <= n;++i) for (int j = 1;j <= n;++j) if (i != j) for (int k = 1;k <= n;++k) if (i != k && j != k) { if (con[i][j] && con[j][k] && con[k][j] && !con[i][k]) add_edge(i, k); } } int32_t main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> n >> m; iota(g, g + n + 1, 0); while (m--) { int a, b; cin >> a >> b; add_edge(a, b); cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...