結果
| 問題 |
No.2689 Populous
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-21 01:11:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 830 bytes |
| コンパイル時間 | 1,726 ms |
| コンパイル使用メモリ | 103,668 KB |
| 実行使用メモリ | 11,432 KB |
| 最終ジャッジ日時 | 2024-09-30 09:53:56 |
| 合計ジャッジ時間 | 2,507 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 1 WA * 27 |
ソースコード
#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);
}