Блог пользователя roycf123

Автор roycf123, история, 4 года назад, По-английски

Hi Everyone,

Today I encountered a new type of problem which involved an interactive task. The problem link is as follows:

https://atcoder.jp/contests/abc269/tasks/abc269_e

These kind of problems are new to me. Nevertheless, I tried solving it and here is my solution (in C++):

#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll t,i,n,a[4];
    cin>>n;
    while(true){
        for(i=0;i<4;i++) a[i]=(rand()%n)+1;
        cout<<"? "<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<endl;
        // cout<<flush;
        cin>>t;
        if(t==0){
            cout<<"! "<<a[1]<<" "<<a[3]<<endl;
            // cout<<flush;
            exit(0);
        }
        if(t==-1) exit(0);
    }
    return 0;
}

I received WA after submitting this solution. I also tried adding "cout<<flush" which are commented now, but that did not help.

Can someone pls help me to correct the solution?

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
4 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Why do you think random numbers can be a solution?

There can be 1000 rows and 1000 columns, but you are only allowed to make 20 queries at most.

»
4 года назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I haven't read this problem but generally binary search is useful in interactive problems

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится