結果

問題 No.2689 Populous
ユーザー kotatsugamekotatsugame
提出日時 2024-03-21 01:11:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 1,857 ms
コンパイル使用メモリ 103,588 KB
実行使用メモリ 11,236 KB
最終ジャッジ日時 2024-03-21 01:11:39
合計ジャッジ時間 3,016 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
8,260 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
8,260 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
#include<atcoder/modint>
#include<atcoder/convolution>
using namespace std;
using mint=atcoder::modint998244353;
int H,W;
int A[1000][1000];
mint dp[1000][1000];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>H>>W;
	for(int i=0;i<W;i++)cin>>A[0][i];
	for(int i=1;i<H-1;i++)cin>>A[i][0]>>A[i][W-1];
	for(int i=0;i<W;i++)cin>>A[H-1][i];
	{
		for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(A[i][j]!=0)
		{
			if(i+1<H&&A[i+1][j]!=0&&abs(A[i][j]-A[i+1][j])>=2)
			{
				cout<<-1<<endl;
				return 0;
			}
			if(j+1<W&&A[i][j+1]!=0&&abs(A[i][j]-A[i][j+1])>=2)
			{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	int h=0,w=0;
	for(int i=1;i<H-1;i++)
	{
		if(abs(A[i][0]-A[i][W-1])>=W)h++;
	}
	for(int i=1;i<W-1;i++)
	{
		if(abs(A[0][i]-A[H-1][i])>=H)w++;
	}
	assert(min(h,w)==0);
}
0