Submission #621875

# Submission time Handle Problem Language Result Execution time Memory
621875 2022-08-04T02:51:38 Z MinaRagy06 Carnival (CEOI14_carnival) C++17
100 / 100
26 ms 464 KB
#include <bits/stdc++.h>
using namespace std;
#define lesgooo ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// #define endl    '\n'
#define int     long long

int ask(vector<int> a)
{
    cout << a.size() << " ";
    for (auto i : a) cout << i << " ";
    cout << endl;
    int ret;
    cin >> ret;
    return ret;
}
signed main()
{
    lesgooo;
    int n;
    cin >> n;
    int par[n]{}, vis[n]{};
    for (int i = 0; i < n; i++) par[i] = i+1;
    int prv = 1;
    for (int i = 1; i < n; i++)
    {
        vector<int> a;
        for (int x = 0; x <= i; x++) a.push_back(x+1);
        if (ask(a) == prv)
        {
            vis[i] = 1;
            for (int j = 0; j < i; j++) if (!vis[j] && ask({i+1, j+1}) == 1) {par[i] = par[j]; break;}
        }
        else prv++;
    }
    set<int> s;
    for (int i = 0; i < n; i++) s.insert(par[i]);
    vector<int> a;
    for (auto i : s) a.push_back(i);
    cout << "0 ";
    for (int i = 0; i < n; i++) cout << lower_bound(a.begin(), a.end(), par[i])-a.begin()+1 << " ";
    cout << endl;
    return 0;
}
/*
2 1 2 3 1
*/
# Verdict Execution time Memory Grader output
1 Correct 17 ms 328 KB Output is correct
2 Correct 17 ms 328 KB Output is correct
3 Correct 17 ms 324 KB Output is correct
4 Correct 4 ms 316 KB Output is correct
5 Correct 7 ms 312 KB Output is correct
6 Correct 5 ms 336 KB Output is correct
7 Correct 8 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 336 KB Output is correct
2 Correct 24 ms 316 KB Output is correct
3 Correct 13 ms 316 KB Output is correct
4 Correct 11 ms 332 KB Output is correct
5 Correct 5 ms 336 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 10 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 8 ms 336 KB Output is correct
3 Correct 26 ms 332 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 3 ms 328 KB Output is correct
6 Correct 8 ms 348 KB Output is correct
7 Correct 16 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 328 KB Output is correct
2 Correct 8 ms 336 KB Output is correct
3 Correct 14 ms 324 KB Output is correct
4 Correct 5 ms 340 KB Output is correct
5 Correct 6 ms 464 KB Output is correct
6 Correct 6 ms 316 KB Output is correct
7 Correct 15 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 368 KB Output is correct
2 Correct 14 ms 344 KB Output is correct
3 Correct 17 ms 320 KB Output is correct
4 Correct 25 ms 328 KB Output is correct
5 Correct 5 ms 328 KB Output is correct
6 Correct 4 ms 356 KB Output is correct
7 Correct 4 ms 312 KB Output is correct