結果

問題 No.1668 Grayscale
ユーザー rianoriano
提出日時 2021-05-15 19:27:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,627 ms / 4,000 ms
コード長 1,319 bytes
コンパイル時間 2,583 ms
コンパイル使用メモリ 178,232 KB
実行使用メモリ 91,384 KB
最終ジャッジ日時 2023-08-21 18:49:26
合計ジャッジ時間 7,813 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 968 ms
91,384 KB
testcase_07 AC 783 ms
90,836 KB
testcase_08 AC 142 ms
11,096 KB
testcase_09 AC 1,627 ms
89,116 KB
testcase_10 AC 669 ms
44,488 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 51 ms
8,348 KB
testcase_14 AC 205 ms
20,984 KB
testcase_15 AC 117 ms
15,296 KB
testcase_16 AC 81 ms
10,516 KB
testcase_17 AC 35 ms
7,204 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,380 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