結果

問題 No.1668 Grayscale
ユーザー 沙耶花
提出日時 2021-09-03 22:31:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 4,587 ms
コンパイル使用メモリ 251,516 KB
最終ジャッジ日時 2025-01-24 06:22:52
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |                         scanf("%d",&A[i][j]);
      |                         ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

int main(){
	
	int H,W,N;
	cin>>H>>W>>N;
	
	vector A(H,vector<int>(W));
	rep(i,H){
		rep(j,W){
			scanf("%d",&A[i][j]);
		}
	}
	
	vector dx = {0,0,1,-1},dy = {1,-1,0,0};
	
	vector<bool> ok(N-1,true);
	
	rep(i,H){
		rep(j,W){
			rep(k,4){
				int ii = i+dx[k],jj = j+dy[k];
				if(ii<0||ii>=H||jj<0||jj>=W)continue;
				if(A[i][j] <= A[ii][jj]){
					if(A[i][j]+1==A[ii][jj]){
						ok[A[i][j]-1] = false;
					}
				}
			}
		}
	}
	int ans = N;
	rep(i,ok.size()){
		if(ok[i])ans--;
	}
	cout<<ans<<endl;
	
	return 0;
}
0