Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- int h, w; cin >> h >> w;
- if (h <= 2) { // edge cases
- for (int i = 0; i < h; ++i) {
- cout << "? " << string(i, 'v') + string(w, '>') << endl;
- int r, c; cin >> r >> c;
- if (r != i) {
- cout << "! " << i << " 0" << endl;
- return 0;
- }
- else if (c != w-1) {
- cout << "! " << r << ' ' << c+1 << endl;
- return 0;
- }
- }
- }
- string s;
- for (int i = 0; i < h+1; ++i) s += string(w, '<') + "v" + string(w, '>') + "^>v";
- cout << "? " << s << endl;
- int r, c; cin >> r >> c;
- if (r == h-1 && c == w-1) {
- // either first row or square 1 0
- cout << "? " << ">vv<^^" << string(w, '>') << endl;
- cin >> r >> c;
- if (r == 2) cout << "! 1 0" << endl;
- else cout << "! 0 " << c+1 << endl;
- } else {
- // try first column
- cout << "? " << string(h, 'v') << endl;
- int r2, c2; cin >> r2 >> c2;
- if (r2 != h-1) cout << "! " << r2+1 << " 0" << endl;
- else cout << "! " << r+1 << ' ' << c << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement