/ 科创班 /

记录详情

Wrong Answer


  
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Accepted 2ms 972.0 KiB
#2 Wrong Answer Standard answer longer than user output. 13ms 924.0 KiB
#3 Accepted 3ms 924.0 KiB
#4 Accepted 2ms 924.0 KiB
#5 Accepted 3ms 924.0 KiB
#6 Accepted 2ms 924.0 KiB
#7 Accepted 2ms 924.0 KiB
#8 Accepted 7ms 924.0 KiB
#9 Wrong Answer Standard answer longer than user output. 8ms 924.0 KiB

代码

#include<stdio.h>
int main(void)
{
	int m, n;
	int a[400][400] = {}, st[100][100] = {};
	scanf("%d %d", &m, &n);
	int i, j;
	for (i = 1; i <= m; i++)
	{
		for (j = 1; j <= n; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	int sum = n * m-1;
	i = j = 1;
	printf("%d ", a[1][1]);
	st[1][1] = 1;
	while (sum > 0)
	{
		if (i < m && j <= n && st[i + 1][j] == 0&&(st[i][j-1]!=0||(st[i][j - 1]==1&&st[i+1][j]==0)||j==1))
		{
			st[i + 1][j] = 1;
			printf("%d", a[i + 1][j]);
			i++;
		}
		else if ((i == m||st[i+1][j]==1) && j < n && st[i][j + 1] == 0)
		{
			st[i][j + 1] = 1;
			printf("%d", a[i][j + 1]);
			j++;
		}
		else if ((j == n||st[i][j+1]==1) && st[i - 1][j] == 0 && i - 1 > 0)
		{
			st[i - 1][j] = 1;
			printf("%d", a[i-1][j]);
			i--;
		}
		else if ((i == 1||st[i-1][j]==1) && st[i][j - 1] == 0 && j - 1 > 0)
		{
			st[i][j - 1] = 1;
			printf("%d", a[i][j - 1]);
			j--;
		}
		sum--;
		if (sum != 0)
			printf(" ");
	}

	return 0;
}

信息

递交者
类型
递交
题目
回形取数
题目数据
下载
语言
C
递交时间
2023-11-10 01:13:31
评测时间
2023-11-10 01:13:31
评测机
分数
80
总耗时
47ms
峰值内存
972.0 KiB