提出 #71664051
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N=500100,INF=2e18,MOD=998244353;
int t,n,k,x,y,z,m,h,j,u,cnt,mi,tt,rr,mx,res,ans,ll,q;
int a[N],b[N],c[N],d[N];
signed main(){
cin>>n;
vector<vector<int>>vis(100,vector<int>(100,0));
vis[0][(n-1)/2]=1;
rr=0;
ll=(n-1)/2;
k=1;
for(int i=1;i<=(n*n-1);i++){
if(vis[(rr-1+n)%n][(ll+1)%n]==0){
vis[(rr-1+n)%n][(ll+1+n)%n]=k+1;
rr=(rr-1+n)%n;
ll=(ll+1)%n;
k++;
}else{
vis[rr+1][ll]=k+1;
rr++;
k++;
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<vis[i][j]<<' ';
}
cout<<endl;
}
}
提出情報
| 提出日時 |
|
| 問題 |
B - Magic Square |
| ユーザ |
mengqing |
| 言語 |
C++23 (GCC 15.2.0) |
| 得点 |
200 |
| コード長 |
798 Byte |
| 結果 |
AC |
| 実行時間 |
2 ms |
| メモリ |
3764 KiB |
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
200 / 200 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_00.txt, 00_sample_01.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
1 ms |
3728 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3592 KiB |
| 01_test_00.txt |
AC |
1 ms |
3764 KiB |
| 01_test_01.txt |
AC |
1 ms |
3728 KiB |
| 01_test_02.txt |
AC |
1 ms |
3520 KiB |
| 01_test_03.txt |
AC |
1 ms |
3544 KiB |
| 01_test_04.txt |
AC |
1 ms |
3728 KiB |
| 01_test_05.txt |
AC |
1 ms |
3752 KiB |
| 01_test_06.txt |
AC |
1 ms |
3680 KiB |
| 01_test_07.txt |
AC |
1 ms |
3544 KiB |
| 01_test_08.txt |
AC |
2 ms |
3608 KiB |
| 01_test_09.txt |
AC |
2 ms |
3712 KiB |
| 01_test_10.txt |
AC |
2 ms |
3712 KiB |