結果

問題 No.1668 Grayscale
ユーザー chocoruskchocorusk
提出日時 2021-09-04 17:17:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 623 ms / 4,000 ms
コード長 1,470 bytes
コンパイル時間 3,426 ms
コンパイル使用メモリ 188,104 KB
実行使用メモリ 62,100 KB
最終ジャッジ日時 2023-08-23 06:15:03
合計ジャッジ時間 7,365 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
27,924 KB
testcase_01 AC 11 ms
28,044 KB
testcase_02 AC 11 ms
28,096 KB
testcase_03 AC 11 ms
27,904 KB
testcase_04 AC 11 ms
27,964 KB
testcase_05 AC 10 ms
27,956 KB
testcase_06 AC 394 ms
62,100 KB
testcase_07 AC 395 ms
62,008 KB
testcase_08 AC 144 ms
30,832 KB
testcase_09 AC 623 ms
55,272 KB
testcase_10 AC 296 ms
44,368 KB
testcase_11 AC 11 ms
27,932 KB
testcase_12 AC 13 ms
30,692 KB
testcase_13 AC 36 ms
29,400 KB
testcase_14 AC 101 ms
32,368 KB
testcase_15 AC 66 ms
30,528 KB
testcase_16 AC 49 ms
32,020 KB
testcase_17 AC 28 ms
30,984 KB
testcase_18 AC 11 ms
27,912 KB
testcase_19 AC 11 ms
27,892 KB
testcase_20 AC 11 ms
27,948 KB
testcase_21 AC 12 ms
30,012 KB
testcase_22 AC 11 ms
27,912 KB
testcase_23 AC 11 ms
27,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
int h, w, n;
int c[1010][1010];
vector<int> v[1000010];
int main()
{
    cin>>h>>w>>n;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>c[i][j]; c[i][j]--;
        }
    }
    for(int i=0; i<h-1; i++){
        for(int j=0; j<w; j++){
            if(c[i][j]!=c[i+1][j]){
                v[max(c[i][j], c[i+1][j])].push_back(min(c[i][j], c[i+1][j]));
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w-1; j++){
            if(c[i][j]!=c[i][j+1]){
                v[max(c[i][j], c[i][j+1])].push_back(min(c[i][j], c[i][j+1]));
            }
        }
    }
    int mx=-1;
    int ans=1;
    for(int i=1; i<n; i++){
        for(auto l:v[i]){
            //cout<<l<<" "<<i<<endl;
            if(mx<l){
                mx=i-1;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
0