結果

問題 No.217 魔方陣を作ろう
ユーザー kosakkun
提出日時 2016-12-06 18:14:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,276 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 91,584 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 03:10:17
合計ジャッジ時間 1,643 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))


int main(){
    
    int N; cin>>N;
    int ans[100][100];
    
    if(N%2==1){
        int cnt=1;
        int sy=0,sx=N/2;
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                ans[sy][sx]=cnt;
                cnt++;
                sy=(sy-1+N)%N;
                sx=(sx+1)%N;
            }
            sy=(sy+2)%N;
            sx=(sx-1+N)%N;
        }
    }
    
    REP(i,N){
        REP(j,N-1)cout<<ans[i][j]<<" ";
        cout<<ans[i][N-1]<<endl;
    }
    
    return 0;
}



0