Advertisement
Rofyda_Elghadban1

Untitled

Feb 16th, 2024
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1.  #include <bits/stdc++.h>
  2.  #define ll long long
  3.  #define ull unsigned long long
  4.  #define pi 3.141592654
  5.  #define NUM 1e18
  6.  #define Mod  1'000'000'007
  7.  #define fixed(n) fixed<<setprecision(n)
  8.  #define cin(v) for(auto &i:v) cin >> i ;
  9.  #define cout(v) for(auto &i:v) cout << i  <<" ";
  10.  #define vowel(x) (x=='e'||x=='a'||x=='i'||x=='o'||x=='u')
  11.  #define small(x) (x>=97&&x<=122)
  12.  #define capital(x) (x>=65&&x<=90)
  13.  #define Tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
  14.  #define Toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
  15.  #define sz(x) (int)(x.size())
  16.  #define all(v) ((v).begin()), ((v).end())
  17.  #define allr(v) ((v).rbegin()), ((v).rend())
  18.  #define updmax(a,b) a=max(a,b)
  19.  #define updmin(a,b) a=min(a,b)
  20.  #define ceil(a,b) ((a/b)+(a%b?1:0))
  21.  /* asc -> 1 2 3 ,des -> 3 2 1 */
  22.  /***********************************************************************************/
  23.  using namespace std;
  24.  void Rofyda_Elghadban(){
  25.   // #ifndef ONLINE_JUDGE  
  26.   //   freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  27.   //  #endif
  28.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  29.  }
  30.  
  31.  void solve(){
  32.   int n;
  33.   cin>>n;
  34.   vector<int>v(n);
  35.   cin(v);
  36.   int l=0,r=n-1,ans=-1;
  37.   while(l<=r){
  38.     ll sum=0;
  39.     int mid=l+(r-l)/2;
  40.     cout<<"? ";
  41.     cout.flush();
  42.     for(int i=l;i<=mid;i++){
  43.       cout<<v[i]<<" ";
  44.       cout.flush();
  45.     }
  46.     for(int i=l;i<=mid;i++){
  47.       sum+=v[i];
  48.     }
  49.     int x;
  50.     cin>>x;
  51.     if(x==sum){
  52.       l=mid+1;
  53.     }else{
  54.       ans=mid;
  55.       r=mid-1;
  56.     }
  57.   }
  58.   cout<<ans+1<<"\n";
  59.  }
  60.  
  61.  int main(){
  62.   Rofyda_Elghadban();
  63.   int t;
  64.   cin>>t;
  65.   while(t--){
  66.     solve();
  67.   }
  68.   // solve();
  69.   return 0;
  70.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement