Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.5 kB
2
Indexable
Never
#include<bits/stdc++.h>
using namespace std;

#define PI pair<int,int>
#define ff first
#define ss second
int main()
{
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        cout<<"? 0 0 1 1\n";
        fflush(stdout);
        char ch;
        cin>>ch;
        int idx;
        if(ch=='<') idx=1;
        else idx=0;
        for(int i=1;i<n;i++){
            printf("? %d %d %d %d\n",idx,idx,i,i);
            fflush(stdout);
            cin>>ch;
            if(ch=='<') idx=i;
        }
        int y=idx;
        vector<int> vec;
        int ara[n];
        int id=1;
        idx=0;
        ara[0]=0;
        for(int i=1;i<n;i++){
            if(i!=y){
                printf("? %d %d %d %d\n",y,idx,y,i);
                fflush(stdout);
                cin>>ch;
                if(ch=='<'){
                    idx=i;
                    id=0;
                    ara[id++]=i;
                }
                else if(ch=='='){
                    ara[id++]=i;
                }
            }
        }
        printf("? %d %d %d %d\n",ara[0],ara[0],ara[1],ara[1]);
        fflush(stdout);
        cin>>ch;
        if(ch=='>') idx=ara[1];
        else idx=ara[0];
        for(int i=2;i<id;i++){
            printf("? %d %d %d %d\n",idx,idx,ara[i],ara[i]);
            fflush(stdout);
            cin>>ch;
            if(ch=='>') idx=ara[i];
        }
        int x=idx;
        printf("! %d %d\n",x,y);\
        fflush(stdout);
    }
    return 0;
}
Leave a Comment