답안 #979011

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979011 2024-05-10T06:10:43 Z The_Samurai 조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2) C++17
0 / 100
2213 ms 712 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 times = 0; times < 3; times++) {
            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';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 2213 ms 712 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 2213 ms 712 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 2213 ms 712 KB Output isn't correct
8 Halted 0 ms 0 KB -