Submission #1042071

# Submission time Handle Problem Language Result Execution time Memory
1042071 2024-08-02T13:57:55 Z AbdullahIshfaq Carnival (CEOI14_carnival) C++14
100 / 100
7 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
ll ask(ll x , ll y){

    cout << y - x + 1 << " ";
	for(int i = x ; i <= y ; i++){
        cout << i << " ";
    }
	cout << endl;
	int c;
    cin >> c;
	return c;
}
void solve(){
    ll w , f , n , summ = 0;
    cin >> n;
    vector<ll> ans(n + 1);
    ans[1] = 1;
    set<ll> st;
    for(int i = 2; i <= n ;i ++){
        st.clear();
        for(int j = 1 ; j <= i -1;j++){
            st.insert(ans[j]);
        }
        ll x = ask(1, i);
        ll siz = st.size();
        if(siz != x){
            ans[i] = x;
            continue;
        }
        ll l = 1,r= i;
        while(r - l > 1){
            ll mid = (l + r) / 2;
            st.clear();
            for(int j = mid; j<= i - 1;j ++){
                st.insert(ans[j]);
            }
            x = ask(mid , i);
            siz = st.size();
            if(siz == x){
                l = mid;
            }
            else{
                r = mid;
            }
        }
        ans[i] = ans[l];
    }
    cout << 0 << " ";
    for(int i = 1; i<=n ; i++){
        cout << ans[i] << " ";
    } 
    cout << endl;

}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tests = 1;
    // cin >> tests;
    for (int i = 1; i <= tests; i++){
        solve();
    }
    return 0;
}

Compilation message

carnival.cpp: In function 'void solve()':
carnival.cpp:17:8: warning: unused variable 'w' [-Wunused-variable]
   17 |     ll w , f , n , summ = 0;
      |        ^
carnival.cpp:17:12: warning: unused variable 'f' [-Wunused-variable]
   17 |     ll w , f , n , summ = 0;
      |            ^
carnival.cpp:17:20: warning: unused variable 'summ' [-Wunused-variable]
   17 |     ll w , f , n , summ = 0;
      |                    ^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 596 KB Output is correct
2 Correct 5 ms 596 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 7 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 444 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 6 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 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 2 ms 340 KB Output is correct