Submission #918213

# Submission time Handle Problem Language Result Execution time Memory
918213 2024-01-29T13:33:18 Z vjudge1 Carnival (CEOI14_carnival) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int coun(int l, int r, int ar[]){
    set<int> s;
    for (int i = l; i <= r; i++){
        s.insert(ar[i]);
    }
    return s.size();
}
string getstr(int l, int r){
    string ans = "";
    for (int i = l; i <= r; i++){
        ans += to_string(i) + " ";
    }
    return ans;
}
int main()
{
    int n, res, col = 2;
    cin>>n;
    int ar[n];
    ar[0] = 1;
    for (int i = 1; i < n; i++){
        cout<<getstr(1, i + 1)<<endl;
        cin>>res;
        int c = coun(0, i - 1, ar);
        if (res > c){
            ar[i] = col;
            col++;
            continue;
        }
        int l = 0, r = i - 1;
        while (true){
            int mid = (l + r) / 2;
            string s = getstr(l + 1, mid + 1) + to_string(i + 1);
            cout<<s<<endl;
            cin>>res;
            c = coun(l, mid, ar);
            if (c == res){
                if (c == 1){
                    ar[i] = ar[l];
                    break;
                }
                else{
                    r = mid;
                }
            }
            else{
                l = mid + 1;
            }
        }
    }
    cout<<"0 ";
    for (int i = 0; i < n; i++){
        cout<<ar[i]<<' ';
    }
    cout<<"\n";
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -