結果

問題 No.223 1マス指定の魔方陣
ユーザー 158b
提出日時 2015-06-07 20:40:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 939 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 72,396 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 14:34:34
合計ジャッジ時間 2,242 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
using namespace std;

#define long __int64
//#define __int64 long long
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vecy[4] = {0,-1,0,1};
const int Vecx[4] = {1,0,-1,0};

int main(){
	const bool first[4][4] = {{1,0,0,1},{0,1,1,0},{0,1,1,0},{1,0,0,1}};
	int field[16][16];
	int n,x,y,z;
	int i;
	int xord;
	
	cin >> n >> x >> y >> z;
	
	i = 0;
	for(int iy=0; iy<n; iy++){
		for(int ix=0; ix<n; ix++){
			field[iy][ix] = i;
			if(first[iy%4][ix%4] == 1){
				field[iy][ix] = n * n - 1 - field[iy][ix];
			}
			i ++;
		}
	}
	
	xord = field[y-1][x-1] ^ (z - 1);
	for(int iy=0; iy<n; iy++){
		for(int ix=0; ix<n; ix++){
			field[iy][ix] = field[iy][ix] ^ xord;
			field[iy][ix] ++;
			cout << field[iy][ix] << " ";
		}
		cout << endl;
	}
	
    return 0;
}
0