結果

問題 No.1668 Grayscale
ユーザー tko919
提出日時 2021-09-04 00:34:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 2,532 ms
コンパイル使用メモリ 202,668 KB
最終ジャッジ日時 2025-01-24 07:29:38
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
   int h,w,n;
   cin>>h>>w>>n;
   vector g(h,vector<int>(w));
   rep(i,0,h)rep(j,0,w)cin>>g[i][j];

   using P=pair<int,int>;
   set<P> col[1010101];
   rep(i,0,h)rep(j,0,w)col[g[i][j]].insert({i,j});
   int res=1;
   rep(c,1,n){
      for(auto& [x,y]:col[c]){
         rep(k,0,4){
            int tx=x+dx[k],ty=y+dy[k];
            if(col[c+1].count({tx,ty})){
               res++;
               goto out;
            }
         }
      }
      out:;
   }
   cout<<res<<'\n';
   return 0;
}
0