結果

問題 No.223 1マス指定の魔方陣
ユーザー 沙耶花沙耶花
提出日時 2021-11-08 21:21:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,032 bytes
コンパイル時間 4,661 ms
コンパイル使用メモリ 265,388 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 07:44:30
合計ジャッジ時間 6,694 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,948 KB
testcase_10 AC 2 ms
6,944 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,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
6,940 KB
testcase_39 AC 2 ms
6,940 KB
testcase_40 AC 2 ms
6,940 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 2 ms
6,944 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:55:16: warning: 'y' may be used uninitialized [-Wmaybe-uninitialized]
   55 |         while(y!=Y){
      |               ~^~~
main.cpp:39:15: note: 'y' was declared here
   39 |         int x,y;
      |               ^
main.cpp:48:16: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized]
   48 |         while(x!=X){
      |               ~^~~
main.cpp:39:13: note: 'x' was declared here
   39 |         int x,y;
      |             ^

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001



int main(){
	int N;
	cin>>N;
	
	vector<vector<int>> ans(N,vector<int>(N));
	rep(i,N){
		rep(j,N){
			ans[i][j] = i*N+j+1;
		}
	}
	
	rep(i,N){
		rep(j,N/2){
			if((i%4==0||i%4==3)&&(j%4==1||j%4==2)){
				swap(ans[i][j],ans[N-1-i][N-1-j]);
			}
			if((i%4==1||i%4==2)&&(j%4==0||j%4==3)){
				swap(ans[i][j],ans[N-1-i][N-1-j]);
			}
			
		}
	}
	
	int X,Y,Z;
	cin>>X>>Y>>Z;
	X--;Y--;
	swap(X,Y);
	int x,y;
	rep(i,N){
		rep(j,N){
			if(ans[i][j]==Z){
				x = i;
				y = j;
			}
		}
	}
	while(x!=X){
		auto t = ans.back();
		ans.pop_back();
		ans.insert(ans.begin(),t);
		x++;
		x%=N;
	}
	while(y!=Y){
		rep(i,N){
			int t = ans[i].back();
			ans[i].pop_back();
			ans[i].insert(ans[i].begin(),t);
		}
		y++;
		y%=N;
	}
	
	rep(i,N){
		rep(j,N){
			if(j!=0)cout<<' ';
			cout<<ans[i][j];
		}
		cout<<endl;
	}
	
	return 0;
}
0