結果
| 問題 | 
                            No.223 1マス指定の魔方陣
                             | 
                    
| コンテスト | |
| ユーザー | 
                             184
                         | 
                    
| 提出日時 | 2015-06-05 23:19:29 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 783 bytes | 
| コンパイル時間 | 558 ms | 
| コンパイル使用メモリ | 67,512 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-06 14:22:46 | 
| 合計ジャッジ時間 | 7,498 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | RE * 1 | 
| other | RE * 46 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:35: warning: format ‘%d’ expects argument of type ‘int*’, but argument 5 has type ‘int’ [-Wformat=]
   16 |         int n,x,y,z;scanf("%d%d%d%d",&n,&x,&y,z);
      |                                  ~^           ~
      |                                   |           |
      |                                   int*        int
main.cpp:16:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         int n,x,y,z;scanf("%d%d%d%d",&n,&x,&y,z);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:16:26: warning: ‘z’ is used uninitialized [-Wuninitialized]
   16 |         int n,x,y,z;scanf("%d%d%d%d",&n,&x,&y,z);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <set>
using namespace std;
//namaega184
int main(){
	int n,x,y,z;scanf("%d%d%d%d",&n,&x,&y,z);
	int a[21][21]={};
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int b=n*i+j+1;
			if(b%4==1||b%4==0)a[i][j]=b; 
			else a[n-1-i][n-1-j]=b;
		}
	}
	int px=0,py=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i][j]==z){px=j,py=i;break;}
		}
	}
	int b[21][21]={}; 
	px-=x,py-=y;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			b[i][j]=a[(j-py+n)%n][(i-px+n)%n];
		}
	} 
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j==0)printf("%d",b[i][j]);
			else printf(" %d",b[i][j]);
		}
		puts("");
	}
	
	return 0; 
}
            
            
            
        
            
184