Submission #226166

#TimeUsernameProblemLanguageResultExecution timeMemory
226166MinnakhmetovMaking Friends on Joitter is Fun (JOI20_joitter2)C++14
1 / 100
55 ms640 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(aaa) aaa.begin(), aaa.end() const int N = 51; int gr[N][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; int ans = 0; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; x--, y--; if (!gr[x][y]) { gr[x][y] = true; ans++; bool work = true; while (work) { work = false; for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { for (int z = 0; z < n; z++) { if (z != x && gr[x][y] && gr[y][z] && gr[z][y] && !gr[x][z]) { gr[x][z] = true; work = true; ans++; } } } } } } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...