제출 #1257006

#제출 시각아이디문제언어결과실행 시간메모리
1257006LucaLucaM조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2)C++20
0 / 100
0 ms320 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cassert> using ll = long long; #define debug(x) #x << " = " << x << '\n' int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(0); int n, m; std::cin >> n >> m; std::vector<std::vector<bool>> g(n, std::vector<bool>(n, false)); int answer = 0; while (m--) { int u, v; std::cin >> u >> v; u--, v--; if (g[u][v]) { continue; } g[u][v] = true; answer++; bool repeat = true; while (repeat) { repeat = false; for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { for (int z = 0; z < n; z++) { if (x != z && g[x][y] && g[y][z] && g[z][y] && !g[x][z]) { g[x][z] = true; repeat = true; answer++; } } } } } std::cout << answer << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...