Submission #710044

# Submission time Handle Problem Language Result Execution time Memory
710044 2023-03-15T04:00:07 Z vjudge1 Carnival (CEOI14_carnival) C++17
100 / 100
8 ms 336 KB
//#pragma GCC optimize ("O2")
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define ld long double
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const ll maxn = 200;
vector<ll> T[200];
vector<ll> pos;
ll A[maxn];
bool ask(ll l, ll r, ll k)
{
    vector<ll> save;
    for(int i = l; i<= r; i++) save.push_back(pos[i]);
    save.push_back(k);
    cout << save.size() << " ";
    for(auto u: save) cout << u << " ";
    cout << endl;
    ll vl; cin >> vl;
    if(vl==save.size()) return 0;
    else return 1;
}
ll n;
void fi(ll l, ll r, ll num)
{
    if(l==r)
    {
        A[num] = l;
        return;
    }
    else
    {
        ll mid = ((l+r)>>1);
        if(ask(l, mid, num)) fi(l, mid, num);
        else fi(mid+1, r, num);
    }
}
void solve()
{
    cin >> n;
    pos.push_back(1);
    A[1] = 0;
    for(int i = 2; i<= n; i++)
    {
        if(!ask(0, pos.size()-1, i))
        {
            pos.push_back(i);
            A[i] = pos.size()-1;
        }
        else
        {
            fi(0, pos.size()-1, i);
        }
    }
    cout << 0 << " ";
    for(int i = 1; i<= n; i++) cout << A[i]+1 << " ";
    cout << endl;
}
signed main()
{
    //ios_base::sync_with_stdio(NULL) ; cin.tie(nullptr) ; cout.tie(nullptr);
    //freopen("case_06.txt","r",stdin);
    //freopen("BAJ.inp","r",stdin);
    //sfreopen("BAJ.out","w",stdout);
    //ll x; cin >> x; Debug(x);
    ll test_case = 1; //cin >> test_case;
    //sang();
    for(int i = 1; i<=test_case; i++)
    {
        //cout << n << " " << m << "\n";
        //if(n==0||m==0) return 0;
        solve();
    }
}

Compilation message

carnival.cpp: In function 'bool ask(long long int, long long int, long long int)':
carnival.cpp:25:10: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     if(vl==save.size()) return 0;
      |        ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 8 ms 308 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 3 ms 312 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 5 ms 312 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 7 ms 308 KB Output is correct
7 Correct 8 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 4 ms 312 KB Output is correct
5 Correct 7 ms 308 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 3 ms 208 KB Output is correct