Submission #995902

# Submission time Handle Problem Language Result Execution time Memory
995902 2024-06-10T03:33:50 Z vjudge1 Carnival (CEOI14_carnival) C++17
100 / 100
14 ms 344 KB
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
 
// #define endl '\n'
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define setmin(x,y) x=min((x),(y))
#define setmax(x,y) x=max((x),(y))
#define fi first
#define se second
 
mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l,int r){return l+((hdp()%(r-l+1))+r-l+1)%(r-l+1);}

const int N = 2e5+5;
const int mod = 998244353;
const int SQ = 450;
const int inf = 1e9+1;

int n,ans[N],cnt,a[N];

// int ask(int l,int r)
// {
//     set<int> s;
//     for(int i=l;i<=r;i++) s.insert(a[i]);
//     return s.size();
// }

int ask(int l,int r)
{
    if(min(l,r)<=0||max(l,r)>n||l>r) return 0;
    cout<<r-l+1<<' ';
    for(int i=l;i<=r;i++) cout<<i<<' ';
    cout<<endl;
    int res; cin>>res;
    return res;
}

signed main()
{
    fastIO
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(ask(1,i)!=ask(1,i-1))
        {
            ans[i]=++cnt;
            continue;
        }
        int r=i,l=1;
        while(l<r-1)
        {
            int m=l+r>>1;
            if(ask(m,i)==ask(m,i-1)) l=m;
            else r=m;
        }
        ans[i]=ans[l];
    }
    cout<<"0 ";
    for(int i=1;i<=n;i++) cout<<ans[i]<<' ';
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:58:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   58 |             int m=l+r>>1;
      |                   ~^~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 9 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 10 ms 344 KB Output is correct
6 Correct 14 ms 344 KB Output is correct
7 Correct 7 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 340 KB Output is correct
2 Correct 12 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 10 ms 344 KB Output is correct
6 Correct 11 ms 344 KB Output is correct
7 Correct 11 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 344 KB Output is correct
2 Correct 10 ms 344 KB Output is correct
3 Correct 11 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 12 ms 344 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 344 KB Output is correct
2 Correct 11 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 8 ms 344 KB Output is correct
6 Correct 10 ms 344 KB Output is correct
7 Correct 9 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 344 KB Output is correct
2 Correct 11 ms 344 KB Output is correct
3 Correct 9 ms 344 KB Output is correct
4 Correct 10 ms 344 KB Output is correct
5 Correct 7 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct