Submission #1356492

#TimeUsernameProblemLanguageResultExecution timeMemory
1356492enzyFind the Box (EGOI23_findthebox)C++20
0 / 100
0 ms412 KiB
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
pii ask(string s){
    cout << "? " << s << endl;
    int x, y; cin >> x >> y;
    return {x,y};
}
bool ini(int n, int m){
    string s;
    for(int i=0;i<m;i++) s.push_back('>');
    for(int i=0;i<n;i++) s.push_back('v');
    pii p=ask(s);
    if(p.fi!=n-1){
        cout << "! " << p.fi+1 << ' ' << m-1 << endl;
        return true;
    }
    if(p.se!=m-1){
        cout << "! " << 0 << ' ' << p.se+1 << endl;
        return true;
    }
    return false;
}
int main(){
    int n, m; cin >> n >> m;
    if(ini(n,m)) return 0;
    string s="", r1="^>v>v", r2="^<<v";
    for(int i=1;i<=m;i++) s.push_back('>');
    s.push_back('v');
    for(int i=1;i<n;i++){
        for(int j=1;j<m-1;j++) s.push_back('<');
        s=s+r2;
        for(int j=1;j<=m-1;j++) s.push_back('>');
        s=s+r1;
    }
    pii p=ask(s);
    if(p.fi==n-1&&p.se==m-1) cout << "1 0" << endl;
    else if(!p.se) cout << "! " << p.fi+1 << ' ' << p.se << endl;
    else cout << "! " << p.fi << ' ' << p.se-1 << endl;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...