Submission #1061546

# Submission time Handle Problem Language Result Execution time Memory
1061546 2024-08-16T10:48:20 Z Zicrus Simurgh (IOI17_simurgh) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;

typedef long long ll;

vector<ll> lnk;

ll find(ll a) {
    if (lnk[a] != a) lnk[a] = find(lnk[a]);
    return lnk[a];
}

bool same(ll a, ll b) {
    return find(a) == find(b);
}

void unite(ll a, ll b) {
    a = find(a); b = find(b);
    lnk[a] = b;
}

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
    int m = u.size();

    for (int i0 = 0; i0 < m; i0++) {
        for (int i1 = i0+1; i1 < m; i1++) {
            for (int i2 = i1+1; i2 < m; i2++) {
                for (int i3 = i2+1; i3 < m; i3++) {
                    for (int i4 = i3+1; i4 < m; i4++) {
                        for (int i5 = i4+1; i5 < m; i5++) {
                            lnk = vector<ll>(n);
                            for (int i = 0; i < n; i++) lnk[i] = i;
                            if (same(u[i0], v[i0])) continue;
                            unite(u[i0], v[i0]);
                            if (same(u[i1], v[i1])) continue;
                            unite(u[i1], v[i1]);
                            if (same(u[i2], v[i2])) continue;
                            unite(u[i2], v[i2]);
                            if (same(u[i3], v[i3])) continue;
                            unite(u[i3], v[i3]);
                            if (same(u[i4], v[i4])) continue;
                            unite(u[i4], v[i4]);
                            if (same(u[i5], v[i5])) continue;
                            unite(u[i5], v[i5]);
                            ll val = count_common_roads({i0, i1, i2, i3, i4, i5});
                            if (val == 6) return {i0, i1, i2, i3, i4, i5};
                            if (val == 5) continue;
                            if (val == 4) break;
                            if (val == 3) goto nw3;
                            if (val == 2) goto nw4;
                            if (val == 1) goto nw5;
                            if (val == 0) goto nw6;
                        }
                        continue;
                        nw3:
                        break;
                    }
                    continue;
                    nw4:
                    break;
                }
                continue;
                nw5:
                break;
            }
            continue;
            nw6:
            break;
        }
    }
    return {};
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB correct
2 Correct 0 ms 348 KB correct
3 Correct 0 ms 348 KB correct
4 Correct 0 ms 344 KB correct
5 Incorrect 0 ms 348 KB WA in grader: NO
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB correct
2 Correct 0 ms 348 KB correct
3 Correct 0 ms 348 KB correct
4 Correct 0 ms 344 KB correct
5 Incorrect 0 ms 348 KB WA in grader: NO
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB correct
2 Correct 0 ms 348 KB correct
3 Correct 0 ms 348 KB correct
4 Correct 0 ms 344 KB correct
5 Incorrect 0 ms 348 KB WA in grader: NO
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB correct
2 Correct 0 ms 348 KB correct
3 Correct 0 ms 348 KB correct
4 Correct 0 ms 344 KB correct
5 Incorrect 0 ms 348 KB WA in grader: NO
6 Halted 0 ms 0 KB -