Submission #531794

# Submission time Handle Problem Language Result Execution time Memory
531794 2022-03-01T14:13:21 Z makanhulia Carnival (CEOI14_carnival) C++17
0 / 100
15 ms 200 KB
#include <bits/stdc++.h>

using namespace std;

int ask(int x, int y){
    int in;
    cout << "2 " << x << " " << y << endl;
    cin >> in;

    return in;
}

int main(){
    int n; cin >> n;
    cout << n << " ";
    for(int i = 1; i <= n; i++) cout << i << " ";
    cout << endl;

    int costumes; cin >> costumes;
    int lc = 1;
    int c[n + 1], p[costumes + 1];
    memset(p, -1, sizeof(p));
    memset(c, -1, sizeof(c));
    c[1] = 1;
    p[1] = 1;

    for(int i = 2; i <= n; i++){
        int tmp = ask(i - 1, i);
        if(tmp == 1) c[i] = c[i - 1];

        else{
            for(int j = 1; j <= costumes; j++){
                if(p[j] == -1 || p[j] == i - 1) continue;
                tmp = ask(i, p[j]);

                if(tmp == 1){
                    c[i] = c[j];
                    break;
                }
            }   

            if(c[i] == -1){
                lc++;
                c[i] = lc;
                p[lc] = i;
            }
        }
    }

    cout << "0 ";
    for(int i = 1; i <= n; i++) cout << c[i] << " ";
    cout << endl;

    return 0;
}

//1 2 3 4 3
//first we need to know how many different costumes exist
//bfta - brute force the answer
//yus
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 200 KB Output is correct
2 Incorrect 6 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 200 KB Output is correct
2 Incorrect 15 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -