제출 #226166

#제출 시각아이디문제언어결과실행 시간메모리
226166Minnakhmetov조이터에서 친구를 만드는건 재밌어 (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...