結果
問題 | No.223 1マス指定の魔方陣 |
ユーザー | tubo28 |
提出日時 | 2015-06-05 23:07:52 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,342 bytes |
コンパイル時間 | 1,415 ms |
コンパイル使用メモリ | 164,844 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 14:21:43 |
合計ジャッジ時間 | 3,152 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,948 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,944 KB |
testcase_15 | AC | 1 ms
6,944 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | WA | - |
testcase_21 | AC | 2 ms
6,944 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 1 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 1 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 2 ms
6,944 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 2 ms
6,944 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 1 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,944 KB |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
ソースコード
#define _CRT_SECURE_NO_WARNINGS //#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; typedef long long ll; //#define int ll //#define endl "\n" typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pii; #define all(c) (c).begin(), (c).end() #define loop(i,a,b) for(ll i=a; i<ll(b); i++) #define rep(i,b) loop(i,0,b) #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple template<class T> ostream & operator<<(ostream & os, vector<T> const &); template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){} template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); } template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; } template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; } template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; } template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; } template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; } #ifdef DEBUG #define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl) #else #define dump(...) #endif // ll const mod = 1000000007; // ll const inf = 1LL<<60; int four[] = { 1,15,14,4, 12,6,7,9, 8,10,11,5, 13,3,2,16 }; int eight[] = { 1,63,62,4,5,59,58,8, 56,10,11,53,52,14,15,49, 48,18,19,45,44,22,23,41, 25,39,38,28,29,35,34,32, 33,31,30,36,37,27,26,40, 24,42,43,21,20,46,47,17, 16,50,51,13,12,54,55,9, 57,7,6,60,61,3,2,64 }; int st[] = { 1,255,254,4,5,251,250,8,9,247,246,12,13,243,242,16, 240,18,19,237,236,22,23,233,232,26,27,229,228,30,31,225, 224,34,35,221,220,38,39,217,216,42,43,213,212,46,47,209, 49,207,206,52,53,203,202,56,57,199,198,60,61,195,194,64, 65,191,190,68,69,187,186,72,73,183,182,76,77,179,178,80, 176,82,83,173,172,86,87,169,168,90,91,165,164,94,95,161, 160,98,99,157,156,102,103,153,152,106,107,149,148,110,111,145, 113,143,142,116,117,139,138,120,121,135,134,124,125,131,130,128, 129,127,126,132,133,123,122,136,137,119,118,140,141,115,114,144, 112,146,147,109,108,150,151,105,104,154,155,101,100,158,159,97, 96,162,163,93,92,166,167,89,88,170,171,85,84,174,175,81, 177,79,78,180,181,75,74,184,185,71,70,188,189,67,66,192, 193,63,62,196,197,59,58,200,201,55,54,204,205,51,50,208, 48,210,211,45,44,214,215,41,40,218,219,37,36,222,223,33, 32,226,227,29,28,230,231,25,24,234,235,21,20,238,239,17, 241,15,14,244,245,11,10,248,249,7,6,252,253,3,2,256 }; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int N,X,Y,Z; cin >> N >> X >> Y >> Z; vi arr; if(N==4) arr = vi(four,four+N*N); if(N==8) arr = vi(eight,eight+N*N); if(N==16) arr = vi(st,st+N*N); vvi g(N,vi(N)); rep(i,N)rep(j,N) g[i][j] = arr[i*N+j]; int ty = -1, tx = -1; rep(i,N)rep(j,N){ if(g[i][j]==Z){ ty = i, tx = j; break; } } X--, Y--; swap(g[Y],g[ty]); rep(i,N) swap(g[i][tx], g[i][X]); rep(i,N)rep(j,N) cout << g[i][j] << (j==N-1 ? "\n" : " "); }