結果

問題 No.217 魔方陣を作ろう
ユーザー snukesnuke
提出日時 2015-05-26 22:58:27
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,672 bytes
コンパイル時間 1,909 ms
コンパイル使用メモリ 77,672 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 15:01:17
合計ジャッジ時間 2,835 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 RE -
testcase_02 AC 2 ms
4,376 KB
testcase_03 RE -
testcase_04 AC 1 ms
4,380 KB
testcase_05 RE -
testcase_06 AC 2 ms
4,376 KB
testcase_07 RE -
testcase_08 AC 1 ms
4,376 KB
testcase_09 RE -
testcase_10 AC 1 ms
4,376 KB
testcase_11 RE -
testcase_12 AC 1 ms
4,376 KB
testcase_13 RE -
testcase_14 AC 2 ms
4,376 KB
testcase_15 RE -
testcase_16 AC 2 ms
4,380 KB
testcase_17 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
#define drep(i,n) for(int i = n-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%2d%c",a[i],i==sz(a)-1?'\n':' ');}

const int MX = 100005, INF = 1000010000;
const ll LINF = 1000000000000000000ll;
const double eps = 1e-10;


vvi odd(int n) {
  vvi a(n, vi(n));
  rep(i,n)rep(j,n) {
    int x = n/2-i+j, y = j*2-x;
    x = (x+n)%n;
    y = (y+n)%n;
    a[y][x] = i*n+j+1;
  }
  return a;
}

vvi even(int n) {
  vvi b = odd(n/2);
  return b;
}

vvi four(int n) {
  return vvi();
}

vvi gen(int n) {
  if (n&1) return odd(n);
  if (n%4) return even(n);
  return four(n);
}

int main() {
  int n;
  scanf("%d",&n);
  vvi a = gen(n);
  rep(i,n) priv(a[i]);
  return 0;
}




0