Submission #1010150

# Submission time Handle Problem Language Result Execution time Memory
1010150 2024-06-28T11:33:14 Z giorgi123glm Carnival (CEOI14_carnival) C++17
0 / 100
10 ms 344 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

using std::cout;
using std::cin;

vector <int> dsu_arr;

const int dsu_parent (int p) {
    return (dsu_arr[p] == p ? p : dsu_arr[p] = dsu_parent (dsu_arr[p]));
}

inline void dsu_join (int a, int b) {
    a = dsu_parent (a), b = dsu_parent (b);
    if (a != b)
        dsu_arr[b] = a;
}

inline const bool check (int I, int L, int R) {
    if (L == R) {
        cout << 2 << ' ' << I << ' ' << L << '\n';
        cout.flush ();
        int out = 0;
        cin >> out;

        if (out == 1)
            return 1;
        return 0;
    }

    cout << R - L + 1 << ' ';
    for (int i = L; i <= R; i++)
        cout << i << ' ';
    cout << '\n';
    cout.flush();

    int out1 = 0;
    cin >> out1;

    cout << R - L + 2 << ' ';
    for (int i = L; i <= R; i++)
        cout << i << ' ';
    cout << I << '\n';
    cout.flush();

    int out2 = 0;
    cin >> out2;

    if (out1 == out2)
        return true;
    return false;
}

int main () {
    int n = 0;
    cin >> n;

    dsu_arr.resize (n + 1);
    
    for (int i = 1; i <= n; i++)
        dsu_arr[i] = i;

    for (int i = 1; i <= n; i++) {
        int L = i + 1, R = n;
        int ans = -1;

        while (L <= R) {
            int mid = (L + R) / 2;

            if (check (i, L, mid)) {
                R = mid - 1;
                ans = mid;
            } else
                L = mid + 1;
        }

        // cout << '\t' << i << ' ' << ans << '\n';
        if (ans != -1)
            dsu_join (i, ans);
    }

    cout << 0 << ' ';
    for (int i = 1; i <= n; i++)
        cout << dsu_parent (i) << ' ';
    cout.flush();
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 344 KB Integer 19 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 344 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 344 KB Output is correct
2 Incorrect 7 ms 344 KB Integer 11 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 344 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 344 KB Output is correct
2 Incorrect 7 ms 344 KB Integer 20 violates the range [1, 17]
3 Halted 0 ms 0 KB -