結果
| 問題 |
No.471 直列回転機
|
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2016-12-21 01:38:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,549 bytes |
| コンパイル時間 | 2,254 ms |
| コンパイル使用メモリ | 183,776 KB |
| 実行使用メモリ | 25,964 KB |
| 平均クエリ数 | 19594.80 |
| 最終ジャッジ日時 | 2024-07-16 11:41:01 |
| 合計ジャッジ時間 | 21,929 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 51 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;
using vb=vector<bool>;using vs=vector<string>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){o<<'('<<p.fst<<", "<<p.snd<<')';return o;}
typedef vector<ll> Vec;
typedef vector<Vec> Mat;
Vec gauss_jordan(const Mat& A, const Vec& b) {
assert(A.size() == A[0].size());
const int n = A.size();
Mat B(n, Vec(n + 1));
for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) B[i][j] = A[i][j];
for (int i = 0; i < n; i++) B[i][n] = b[i];
for (int i = 0; i < n; i++) {
int pivot = i;
for (int j = i; j < n; j++) if (abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
swap(B[i], B[pivot]);
if (abs(B[i][i]) == 0) return Vec();
for (int j = i + 1; j <= n; j++) B[i][j] /= B[i][i];
for (int j = 0; j < n; j++) {
if (i != j) {
for (int k = i + 1; k <= n; k++) B[j][k] -= B[j][i] * B[i][k];
}
}
}
Vec x(n);
for (int i = 0; i < n; i++) x[i] = B[i][n];
return x;
}
using point = complex<ll>;
int m;
vector<point> P;
point query(int qx, int qy) {
_p("? %d %d\n", qx, qy);
fflush(stdout);
ll x, y;
scanf("%lld%lld", &x, &y);
return {x, y};
}
void output(const vector<point> ans) {
_p("!\n");
forr(p, ans) _p("%lld %lld\n", p.real(), p.imag());
fflush(stdout);
}
void Main() {
scanf("%d", &m);
rep(i, m) {
int x, y;
scanf("%d%d", &x, &y);
P.emplace_back(x, y);
}
/*
*/
if (m <= 10) {
vector<point> ans;
forr(p, P) {
ans.emplace_back(query(p.real(), p.imag()));
}
output(ans);
return;
}
vector<point> Q;
rep(x, 3) rep (y, 3) {
Q.emplace_back(query(100 * x, 100 * y));
}
int q = sz(Q);
rep(i, q) rep(j, i+1, q) rep(k, j+1, q) {
Mat a = {
{P[i].real(), P[i].imag(), 1},
{P[j].real(), P[j].imag(), 1},
{P[k].real(), P[k].imag(), 1},
};
Vec b1 = {Q[i].real(), Q[j].real(), Q[k].real()};
Vec b2 = {Q[i].imag(), Q[j].imag(), Q[k].imag()};
Vec b3 = {1, 1, 1};
Vec x1 = gauss_jordan(a, b1);
Vec x2 = gauss_jordan(a, b2);
Vec x3 = gauss_jordan(a, b3);
if (sz(x1) && sz(x2) && sz(x3)) {
vector<point> ans;
bool ok = 1;
forr(p, P) {
ll nx = x1[0] * p.real() + x1[1] * p.imag() + x1[2];
ll ny = x2[0] * p.real() + x2[1] * p.imag() + x2[2];
ll nz = x3[0] * p.real() + x3[1] * p.imag() + x3[2];
if (nz != 1) {
ok = false;
continue;
}
ans.emplace_back(nx, ny);
}
if (ok) {
output(ans);
return;
}
}
}
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }
しらっ亭