提出 #49048235


ソースコード 拡げる

#include<stdio.h>
int a[45][45];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main(){
	int n;
	scanf("%d",&n);
	int x=0,y=0;
	int k=1;
	int crr=1;
	a[0][0]=1;
	while(crr<n*n){
		int xx=x+dx[k];
		int yy=y+dy[k];
		if(0<=xx&&xx<n&&0<=yy&&yy<n&&a[xx][yy]==0){
			a[xx][yy]=++crr;
			x=xx;
			y=yy;
		}else{
			k=(k+1)%4;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j)printf(" ");
			if(a[i][j]==n*n){
				printf("T");
			}else{
				printf("%d",a[i][j]);
			}
		}
		puts("");
	}
}

提出情報

提出日時
問題 D - Loong and Takahashi
ユーザ kyopro_friends
言語 C (gcc 12.2.0)
得点 350
コード長 534 Byte
結果 AC
実行時間 2 ms
メモリ 1716 KiB

コンパイルエラー

Main.c: In function ‘main’:
Main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d",&n);
      |         ^~~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 350 / 350
結果
AC × 1
AC × 22
セット名 テストケース
Sample sample_01.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 0 ms 1660 KiB
random_02.txt AC 1 ms 1708 KiB
random_03.txt AC 0 ms 1704 KiB
random_04.txt AC 0 ms 1628 KiB
random_05.txt AC 0 ms 1712 KiB
random_06.txt AC 0 ms 1672 KiB
random_07.txt AC 0 ms 1632 KiB
random_08.txt AC 1 ms 1612 KiB
random_09.txt AC 0 ms 1544 KiB
random_10.txt AC 2 ms 1620 KiB
random_11.txt AC 1 ms 1708 KiB
random_12.txt AC 0 ms 1612 KiB
random_13.txt AC 0 ms 1592 KiB
random_14.txt AC 0 ms 1620 KiB
random_15.txt AC 0 ms 1716 KiB
random_16.txt AC 0 ms 1620 KiB
random_17.txt AC 1 ms 1628 KiB
random_18.txt AC 0 ms 1592 KiB
random_19.txt AC 0 ms 1708 KiB
random_20.txt AC 0 ms 1588 KiB
random_21.txt AC 0 ms 1692 KiB
sample_01.txt AC 0 ms 1596 KiB