結果

問題 No.1668 Grayscale
ユーザー rianoriano
提出日時 2021-05-15 19:28:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 662 ms / 4,000 ms
コード長 1,329 bytes
コンパイル時間 1,875 ms
コンパイル使用メモリ 174,804 KB
実行使用メモリ 45,216 KB
最終ジャッジ日時 2024-05-09 00:32:47
合計ジャッジ時間 6,205 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 662 ms
45,216 KB
testcase_07 AC 582 ms
44,356 KB
testcase_08 AC 148 ms
11,268 KB
testcase_09 AC 571 ms
44,312 KB
testcase_10 AC 538 ms
44,564 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 33 ms
6,940 KB
testcase_14 AC 108 ms
13,376 KB
testcase_15 AC 80 ms
13,848 KB
testcase_16 AC 62 ms
9,148 KB
testcase_17 AC 24 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 3 ms
6,944 KB
testcase_21 AC 3 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Pr pair<ll,ll>
#define Tp tuple<ll,ll,ll>
using Graph = vector<vector<Pr>>;

ll mod = 998244353;

int main() {
    //FILE *in = freopen("in/sample3.txt", "r", stdin);
    //FILE *out = freopen("out/sample3.txt", "w", stdout);
    ll H,W,N; cin >> H >> W >> N;
    //assert(1<=H&&H<=1000&&1<=W&&W<=1000&&1<=N&&N<=H*W);
    ll col[H][W];
    //set<ll> num;
    rep(i,H){
        rep(j,W){
            cin >> col[i][j];
            //assert(1<=col[i][j]&&col[i][j]<=2000000000);
            //num.insert(col[i][j]);
        }
    }
    //assert(num.size()==N);
    vector<Pr> range;
    rep(i,H){
        rep(j,W-1){
            ll a = col[i][j], b = col[i][j+1];
            if(a==b) continue;
            if(a>b) swap(a,b);
            range.push_back(make_pair(b,a));
        }
    }
    rep(i,H-1){
        rep(j,W){
            ll a = col[i][j], b = col[i+1][j];
            if(a==b) continue;
            if(a>b) swap(a,b);
            range.push_back(make_pair(b,a));
        }
    }
    sort(range.begin(),range.end());
    ll end = 0;
    ll ans = 1;
    for(auto p:range){
        ll a = p.second, b = p.first;
        if(a>=end){
            ans++; end = b;
        }
    }
    cout << ans << endl;
}
0