結果
| 問題 |
No.223 1マス指定の魔方陣
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-11-08 21:21:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,032 bytes |
| コンパイル時間 | 3,670 ms |
| コンパイル使用メモリ | 253,856 KB |
| 最終ジャッジ日時 | 2025-01-25 14:50:43 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 29 WA * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
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;
| ^
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;
| ^
ソースコード
#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;
}
沙耶花