1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| #include<bits/stdc++.h> #define x first #define y second #define ok cout << "ok" << endl; using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const long double PI = acos(-1.0); const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; const double Eps = 1e-7; const int N = 1e5+9;
int n, a[509][509], x, y; pii pre[509][509]; string s;
bool ask(int x, int y, int xx, int yy) { cout << "? " << x << " " << y << " " << xx << " " << yy << endl; cin >> s; return s[0] == 'Y'; }
int main(void) { if(fopen("in", "r")!=NULL) {freopen("in", "r", stdin); freopen("out", "w", stdout);} ios::sync_with_stdio(false); cin.tie(0); cin >> n; x = 1, y = 1; for(int i = 1; i < n; i++) { if(ask(x + 1, y, n, n)) { x++; a[x][y]++; pre[x][y] = pii(x - 1, y); } else { y++; a[x][y]++; pre[x][y] = pii(x, y - 1); } } string ans; while(!(x == 1 && y == 1)) { if(pre[x][y].x == x) { y--; ans += 'R'; } else { x--; ans += 'D'; } } reverse(ans.begin(), ans.end()); x = n, y = n; for(int i = 1; i < n; i++) { if(ask(1, 1, x, y - 1)) { y--; a[x][y]++; pre[x][y] = pii(x, y + 1); } else { x--; a[x][y]++; pre[x][y] = pii(x + 1, y); } } while(!(x == n && y == n)) { if(pre[x][y].x == x) { y++; ans += 'R'; } else { x++; ans += 'D'; } } cout << "! " << ans << endl;
return 0; }
|