Submission #979009

# Submission time Handle Problem Language Result Execution time Memory
979009 2024-05-10T06:09:02 Z The_Samurai Making Friends on Joitter is Fun (JOI20_joitter2) C++17
0 / 100
1 ms 348 KB
#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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -