제출 #930393

#제출 시각아이디문제언어결과실행 시간메모리
930393boris_mihov조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2)C++17
1 / 100
51 ms856 KiB
#include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> #include <queue> #include <set> #include <map> typedef long long llong; const int MAXN = 50 + 10; const int MAXM = 30000 + 10; const int MOD = 1e9 + 7; int n, m; bool active[MAXN][MAXN]; int from[MAXM]; int to[MAXM]; void run() { bool shouldCall = false; for (int x1 = 1 ; x1 <= n ; ++x1) { for (int x2 = 1 ; x2 <= n ; ++x2) { for (int x3 = 1 ; x3 <= n ; ++x3) { if (x1 == x2 || x2 == x3 || x1 == x3) continue; if (active[x1][x2] && active[x2][x3] && active[x3][x2] && !active[x1][x3]) { active[x1][x3] = true; shouldCall = true; } } } } if (shouldCall) { run(); } } int ans; void calc() { int res = 0; for (int x1 = 1 ; x1 <= n ; ++x1) { for (int x2 = 1 ; x2 <= n ; ++x2) { res += active[x1][x2]; } } ans = res; } void solve() { for (int i = 1 ; i <= m ; ++i) { bool shouldRun = !active[from[i]][to[i]]; active[from[i]][to[i]] = true; if (shouldRun) { run(); calc(); } std::cout << ans << '\n'; } } void input() { std::cin >> n >> m; for (int i = 1 ; i <= m ; ++i) { std::cin >> from[i] >> to[i]; } } void fastIOI() { std::ios_base :: sync_with_stdio(0); std::cout.tie(nullptr); std::cin.tie(nullptr); } int main() { fastIOI(); input(); solve(); return 0; } /* 14 13 10 14 3 10 14 13 1 3 3 5 3 11 12 14 14 6 11 8 2 3 7 8 9 7 1 4 5 6 4 2 1 5 2 3 2 5 3 2 3 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...