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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
| #include <algorithm> #include <bits/stdc++.h> #define all(vec) vec.begin(),vec.end() #define PB push_back #define EB emplace_back #define EM emplace #define FI first #define SE second #define pct __builtin_popcountll #define ctz __builtin_ctzll #define SZ(a) ((long long) a.size()) #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define ROF(i, a, b) for (int i = (a); i >= (b); --i) #define debug(var) cerr << #var <<":"<<var<<"\n"; #define cend cerr<<"\n-----------\n" #define fsp(x) fixed<<setprecision(x) #define minn(vec) *min_element(vec.begin(),vec.end()) #define maxx(vec) *max_element(vec.begin(),vec.end()) using namespace std; #ifdef LOCAL template<typename T> void _print(T x) { cerr << x; }
template<typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) _print(i), cerr << " "; cerr << "]"; } template<typename T> void _print(set<T> s) { cerr << "{ "; for (T i : s) _print(i), cerr << " "; cerr << "}"; } template<typename T, typename U> void _print(pair<T, U> p) { cerr << "{"; _print(p.first); cerr << ", "; _print(p.second); cerr << "}"; } template<typename T, typename U> void _print(map<T, U> m) { cerr << "{ "; for (auto &p : m) _print(p), cerr << " "; cerr << "}"; }
template<typename T> void _print(vector<vector<T>> v){cerr<<"{\n";for (auto i : v) _print(i), cerr << "\n";cerr<<" }";} #endif
using ll = long long;using ull = unsigned long long; using ld=double;using LD=long double; using i128 = __int128; using pdd = pair<ld,ld>;using plb = pair<ll,bool>; using pll = pair<ll,ll>;using vll=vector<ll>;using vb=vector<bool>; using tll = tuple<ll,ll,ll>;using vii=vector<int>; using vpll = vector<pll>;using vtll = vector<tll>; using vdb = vector<ld>;using vc=vector<char>; using arr3 = array<ll,3> ;using arr2 = array<ll,2>; using CD=complex<double>; static constexpr ll MAXN=(ll)1e6+10,INF=(ll)1e17+3; static constexpr ll mod=(ll)1e9; static constexpr double eps=1e-8;const double pi=acos(-1.0); ll N,M,Q,X,K,T,lT;
inline void __(); signed main() { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin>>lT; while(lT--) __(); return 0; }
using Real = ll; using Point = complex<Real>; #define x() real() #define y() imag() Real cross(const Point &a, const Point &b) { return (conj(a) * b).imag(); } Real dot(const Point &a, const Point &b) { return (conj(a) * b).real(); } Real mandis(const Point &a,const Point &b){ return abs(a.x()-b.x())+abs(a.y()-b.y()); } int sgn(Real x) { if (-eps < x && x < eps) return 0; return x < 0 ? -1 : 1; } namespace std { bool operator <(const Point& a, const Point& b){ return sgn(real(a) - real(b)) ? real(a) < real(b) : imag(a) < imag(b); } bool operator ==(const Point& a, const Point& b){ if(!sgn(a.imag()-b.imag()) && !sgn(a.real()-b.real())){ return true; } return false; } bool operator !=(const Point& a, const Point& b){ if(!sgn(a.imag()-b.imag()) && !sgn(a.real()-b.real())){ return false; } return true; } istream& operator>>(istream& in, Point& c) { Real r, i; in >> r >> i; c = Point(r, i); return in; } }
struct Line{ Point a,b; Line(){} Line(Point a,Point b):a(a),b(b) {} bool operator<(const Line&other) const{ return a!=other.a?a<other.a:b<other.b; } bool operator==(const Line&other) const{ return a==other.a && b==other.b; } }; istream& operator>>(istream& in, Line& e) { Real a,b,c,d; in >> a >> b >> c >> d; e = Line(Point(a,b),Point(c,d)); return in; }
Point getintersect(const Line &a,const Line &b){ Point p=a.a, v=a.b-a.a,q=b.a,w=b.b-b.a; Point u=p-q; Real t=cross(w,u)/cross(v,w); return p+v*t; } bool isseginterline(Line seg,Line e){ if(sgn(cross(e.a-seg.a, e.b-seg.a))*sgn(cross(e.a-seg.b, e.b-seg.b))>0){ return false; } return true; } ll ask(char a,ll b){ cout<<"? "<<a<<" "<<b<<endl; ll res;cin>>res; return res; } inline void __(){ cin>>N; if(N==-1) exit(0); vector<Point> A; FOR(i,1,N){ Point a;cin>>a; A.EB(a); } ask('R',mod); ask('R',mod); ask('U',mod); ll dis=ask('U',mod); sort(all(A),[&](Point a,Point b){ return 2*2*mod-a.x()-a.y() < 2*2*mod-b.x()-b.y(); }); Point a=A[0]; ll XY=dis-2*2*mod+a.x()+a.y();
ask('D',mod); ask('D', mod); ask('D',mod); ll dis2=ask('D', mod); sort(all(A),[&](Point a,Point b){ return 2*2*mod-a.x()+a.y() < 2*2*mod-b.x()+b.y(); }); a=A[0]; ll X_Y=dis2+a.x()-a.y()-2*2*mod;
ll X=(XY+X_Y)/2; ll Y=XY-X; cout<<"! "<<X<<" "<<Y<<endl; }
|