제출 #979009

#제출 시각아이디문제언어결과실행 시간메모리
979009The_Samurai조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2)C++17
0 / 100
1 ms348 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; ll get(int l, int r = -1) { if (r == -1) return 1ll * l * (l + 1) / 2; return 1ll * (r - l + 1) * (l + r) / 2; } void solve() { int n, m; cin >> n >> m; int ans = 0; vector con(n + 1, vector(n + 1, false)); while (m--) { int u, v; cin >> u >> v; if (!con[u][v]) ans++; con[u][v] = true; for (int x = 1; x <= n; x++) { for (int y = 1; y <= n; y++) { if (x == y or !con[x][y]) continue; for (int z = 1; z <= n; z++) { if (x == z or y == z or !con[y][z] or !con[z][y]) continue; // cout << x << ' ' << y << ' ' << z << endl; if (!con[x][z]) ans++; con[x][z] = true; } } } cout << ans << '\n'; } } int main() { cin.tie(0)->sync_with_stdio(false); int queries = 1; #ifdef sunnatov freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // cin >> queries; for (int test_case = 1; test_case <= queries; test_case++) { #ifdef sunnatov cout << "Test case: " << test_case << endl; #endif solve(); cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...