結果

問題 No.1668 Grayscale
ユーザー tko919tko919
提出日時 2021-09-04 00:34:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 210,060 KB
実行使用メモリ 101,552 KB
最終ジャッジ日時 2023-08-22 03:15:12
合計ジャッジ時間 8,090 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
50,732 KB
testcase_01 AC 20 ms
50,864 KB
testcase_02 AC 18 ms
50,832 KB
testcase_03 AC 19 ms
50,672 KB
testcase_04 AC 19 ms
50,672 KB
testcase_05 AC 19 ms
50,708 KB
testcase_06 AC 397 ms
101,516 KB
testcase_07 AC 405 ms
101,552 KB
testcase_08 AC 486 ms
101,524 KB
testcase_09 WA -
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 AC 19 ms
50,696 KB
testcase_23 AC 19 ms
50,804 KB
権限があれば一括ダウンロードができます

ソースコード

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