提出 #12312278


ソースコード 拡げる

//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
const int N = 100 + 10;
int n, m, dp[N][N], a[N][N];
char buf[N];
int main()
{
	n = read(), m = read();
	for (int i = 1; i <= n; ++i)
	{
		scanf("%s", buf + 1);
		for (int j = 1; j <= m; ++j)
			a[i][j] = buf[j] == '#';
	}
	dp[1][1] = a[1][1];
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			if (i == 1 && j == 1)
				continue;
			int val = n * m;
			if (i > 1)
				val = min(val, dp[i - 1][j] + (a[i][j] == 1 && a[i - 1][j] == 0));
			if (j > 1)
				val = min(val, dp[i][j - 1] + (a[i][j] == 1 && a[i][j - 1] == 0));
			dp[i][j] = val;
		}
	printf("%d\n", dp[n][m]);
	return 0;
}

提出情報

提出日時
問題 A - Range Flip Find Route
ユーザ KaguraMea
言語 C++14 (GCC 5.4.1)
得点 400
コード長 986 Byte
結果 AC
実行時間 1 ms
メモリ 384 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", buf + 1);
                       ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 4
AC × 17
セット名 テストケース
Sample example_00, example_01, example_02, example_03
All corner_00, corner_01, example_00, example_01, example_02, example_03, kuronuri_00, max_answer_00, max_answer_01, max_answer_02, max_random_00, max_random_01, max_random_02, max_random_03, one_path_00, one_path_01, one_path_02
ケース名 結果 実行時間 メモリ
corner_00 AC 1 ms 384 KiB
corner_01 AC 1 ms 384 KiB
example_00 AC 1 ms 256 KiB
example_01 AC 1 ms 256 KiB
example_02 AC 1 ms 256 KiB
example_03 AC 1 ms 256 KiB
kuronuri_00 AC 1 ms 384 KiB
max_answer_00 AC 1 ms 384 KiB
max_answer_01 AC 1 ms 384 KiB
max_answer_02 AC 1 ms 384 KiB
max_random_00 AC 1 ms 384 KiB
max_random_01 AC 1 ms 384 KiB
max_random_02 AC 1 ms 384 KiB
max_random_03 AC 1 ms 384 KiB
one_path_00 AC 1 ms 384 KiB
one_path_01 AC 1 ms 384 KiB
one_path_02 AC 1 ms 384 KiB