結果
問題 | No.471 直列回転機 |
ユーザー | chaemon |
提出日時 | 2016-12-22 01:24:45 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 357 ms / 3,141 ms |
コード長 | 4,373 bytes |
コンパイル時間 | 2,008 ms |
コンパイル使用メモリ | 174,700 KB |
実行使用メモリ | 25,592 KB |
平均クエリ数 | 19589.39 |
最終ジャッジ日時 | 2024-06-11 10:31:00 |
合計ジャッジ時間 | 13,326 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
24,836 KB |
testcase_01 | AC | 19 ms
25,196 KB |
testcase_02 | AC | 19 ms
25,324 KB |
testcase_03 | AC | 22 ms
24,800 KB |
testcase_04 | AC | 21 ms
24,680 KB |
testcase_05 | AC | 20 ms
24,812 KB |
testcase_06 | AC | 19 ms
25,196 KB |
testcase_07 | AC | 21 ms
25,196 KB |
testcase_08 | AC | 44 ms
25,112 KB |
testcase_09 | AC | 47 ms
24,428 KB |
testcase_10 | AC | 29 ms
24,812 KB |
testcase_11 | AC | 145 ms
25,184 KB |
testcase_12 | AC | 275 ms
24,580 KB |
testcase_13 | AC | 279 ms
25,484 KB |
testcase_14 | AC | 308 ms
24,916 KB |
testcase_15 | AC | 357 ms
24,964 KB |
testcase_16 | AC | 22 ms
24,824 KB |
testcase_17 | AC | 20 ms
24,940 KB |
testcase_18 | AC | 19 ms
24,812 KB |
testcase_19 | AC | 19 ms
24,556 KB |
testcase_20 | AC | 329 ms
25,208 KB |
testcase_21 | AC | 80 ms
24,952 KB |
testcase_22 | AC | 306 ms
24,824 KB |
testcase_23 | AC | 262 ms
24,824 KB |
testcase_24 | AC | 161 ms
24,568 KB |
testcase_25 | AC | 67 ms
24,952 KB |
testcase_26 | AC | 308 ms
24,568 KB |
testcase_27 | AC | 151 ms
24,824 KB |
testcase_28 | AC | 180 ms
25,208 KB |
testcase_29 | AC | 226 ms
25,208 KB |
testcase_30 | AC | 104 ms
25,208 KB |
testcase_31 | AC | 348 ms
24,824 KB |
testcase_32 | AC | 272 ms
25,208 KB |
testcase_33 | AC | 220 ms
25,592 KB |
testcase_34 | AC | 310 ms
24,952 KB |
testcase_35 | AC | 88 ms
25,208 KB |
testcase_36 | AC | 133 ms
24,824 KB |
testcase_37 | AC | 46 ms
24,824 KB |
testcase_38 | AC | 74 ms
25,208 KB |
testcase_39 | AC | 117 ms
24,836 KB |
testcase_40 | AC | 226 ms
25,208 KB |
testcase_41 | AC | 316 ms
24,940 KB |
testcase_42 | AC | 191 ms
25,592 KB |
testcase_43 | AC | 292 ms
25,464 KB |
testcase_44 | AC | 50 ms
25,208 KB |
testcase_45 | AC | 199 ms
24,952 KB |
testcase_46 | AC | 234 ms
24,952 KB |
testcase_47 | AC | 296 ms
24,952 KB |
testcase_48 | AC | 254 ms
24,824 KB |
testcase_49 | AC | 240 ms
24,824 KB |
testcase_50 | AC | 282 ms
24,824 KB |
testcase_51 | AC | 132 ms
24,824 KB |
testcase_52 | AC | 22 ms
25,068 KB |
testcase_53 | AC | 23 ms
24,812 KB |
testcase_54 | AC | 24 ms
25,196 KB |
testcase_55 | AC | 92 ms
25,196 KB |
testcase_56 | AC | 88 ms
25,184 KB |
testcase_57 | AC | 59 ms
25,324 KB |
testcase_58 | AC | 31 ms
24,940 KB |
ソースコード
// #includes {{{ #include <bits/stdc++.h> using namespace std; // }}} // pre-written code {{{ #define REP(i,n) for(int i=0;i<(int)(n);++i) #define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i) #define LET(x,a) __typeof(a) x(a) //#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i) #define ALL(c) (c).begin(), (c).end() #define MP make_pair #define EXIST(e,s) ((s).find(e)!=(s).end()) #define RESET(a) memset((a),0,sizeof(a)) #define SET(a) memset((a),-1,sizeof(a)) #define PB push_back #define DEC(it,command) __typeof(command) it=command //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; #define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl; const int INF=0x3f3f3f3f; typedef long long Int; typedef unsigned long long uInt; #ifdef __MINGW32__ typedef double rn; #else typedef long double rn; #endif typedef pair<int,int> pii; /* #ifdef MYDEBUG #include"debug.h" #include"print.h" #endif */ // }}} //{{{ mat typedef rn Num; typedef vector<Num> vec; typedef vector<vec> mat; //int /* Num add(const Num &x,const Num &y){return (x+y)%mod;} Num opposite(const Num &n){return ((-n)%mod+mod)%mod;} Num mul(const Num &x,const Num &y){return (unsigned long long)x*y%mod;} //Num inverse(const Num &n){return invMod(n,mod);} //Num modulo(const Num &n,int mod=::mod){return ((n+mod)%mod+mod)%mod;} */ //real number Num add(const Num &x,const Num &y){return x+y;} Num opposite(const Num &n){return -n;} Num mul(const Num &x,const Num &y){return x*y;} Num inverse(const Num &n){return 1L/n;} // O( n ) mat identity(int n) { mat A(n, vec(n)); for (int i = 0; i < n; ++i) A[i][i] = 1; return A; } // O( n ) Num inner_product(const vec &a, const vec &b) { Num ans = 0; for (int i = 0; i < a.size(); ++i) ans = add(ans,mul(a[i],b[i])); return ans; } mat add(const mat &A, const mat &B) { mat C(A.size(), vec(B[0].size())); for (int i = 0; i < C.size(); ++i) for (int j = 0; j < C[i].size(); ++j) C[i][j] = add(A[i][j],B[i][j]); return C; } // O( n^2 ) vec mul(const mat &A, const vec &x) { vec y(A.size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < A[0].size(); ++j) y[i] = add(y[i], mul(A[i][j],x[j])); return y; } // O( n^3 ) mat mul(const mat &A, const mat &B) { mat C(A.size(), vec(B[0].size())); for (int i = 0; i < C.size(); ++i) for (int j = 0; j < C[i].size(); ++j) for (int k = 0; k < A[i].size(); ++k) C[i][j] = add(C[i][j],mul(A[i][k],B[k][j])); return C; } // O( n^3 log e ) mat pow(const mat &A, long long e) { return e == 0 ? identity(A.size()) : e % 2 == 0 ? pow(mul(A, A), e/2) : mul(A, pow(A, e-1)); } //}}} //{{{ gauss int gauss(mat &A, vec &b) { //int gauss(mat& A) {//returns rank const int n=A.size(),m=A[0].size(); int pi=0; for(int pj=0;pj<m;pj++){ for(int i = pi+1; i < n; i++) { if (abs(A[i][pj]) > abs(A[pi][pj])) { swap(A[i], A[pi]); swap(b[i], b[pi]); } } if (abs(A[pi][pj]) > 0) { Num d = inverse(A[pi][pj]); REP(j, m) A[pi][j] = mul(A[pi][j],d); b[pi] = mul(b[pi],d); REP(i,n){ if(i==pi)continue; Num k = A[i][pj]; REP(j, m) A[i][j] = add(A[i][j],opposite(mul(k, A[pi][j]))); b[i] = add(b[i],opposite(mul(k, b[pi]))); } pi++; } } return pi; /* for(int i = pi; i < n; i++) if (abs(b[i]) > 0) throw Inconsistent(); if (pi < m || pj < m) throw Ambiguous(); for(int j = m-1; j >= 0; j--) REP(i, j) b[i] = modulo(b[i] - b[j] * A[i][j]); */ } //}}} int x[55555],y[55555]; int main(){ // printf("%.0Lf",12.34L); int M; scanf("%d",&M); REP(i,M){ scanf("%d%d",x+i,y+i); } const int T = 3; mat A(6,vec(6)); vec b(6); REP(i,T){ int x = rand()%20000-10000; int y = rand()%20000-10000; printf("? %d %d\n",x,y); fflush(stdout); long long a0,b0; scanf("%lld%lld",&a0,&b0); A[i*2][0] = (rn)x; A[i*2][1] = (rn)y; A[i*2][2] = 1.0L; A[i*2+1][3] = (rn)x; A[i*2+1][4] = (rn)y; A[i*2+1][5] = 1.0L; b[i*2] = (rn)a0; b[i*2+1] = (rn)b0; } gauss(A,b); printf("!\n"); REP(i,M){ printf("%.0Lf %.0Lf\n",b[0]*x[i]+b[1]*y[i]+b[2],b[3]*x[i]+b[4]*y[i]+b[5]); } fflush(stdout); return 0; }