結果
| 問題 |
No.1668 Grayscale
|
| コンテスト | |
| ユーザー |
harurun
|
| 提出日時 | 2021-09-03 22:09:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 834 ms / 4,000 ms |
| コード長 | 1,172 bytes |
| コンパイル時間 | 1,046 ms |
| コンパイル使用メモリ | 83,516 KB |
| 最終ジャッジ日時 | 2025-01-24 05:54:35 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
using ll=long long;
int main(){
ll H,W,N;
cin>>H>>W>>N;
vector<vector<ll>>C(H,vector<ll>(W));
vector<vector<pair<ll,ll>>>d(N);
for(ll i=0;i<H;i++){
for(ll j=0;j<W;j++){
cin>>C.at(i).at(j);
C.at(i).at(j)--;
d.at(C.at(i).at(j)).emplace_back(make_pair(i,j));
}
}
//cerr<<"input\n";
ll ans=0,x,y,start=0;
bool flag;
const vector<pair<ll,ll>> around={{1,0},{0,1},{-1,0},{0,-1}};
for(ll i=0;i<N;i++){
flag=true;
for(pair<ll,ll> j:d.at(i)){
x=j.first;
y=j.second;
for(pair<ll,ll> k:around){
if(0<=x+k.first && x+k.first<H && 0<=y+k.second && y+k.second<W){
if(C.at(x+k.first).at(y+k.second)>=start
&& C.at(x).at(y)>C.at(x+k.first).at(y+k.second)){
ans++;
flag=false;
start=C.at(x).at(y);
//cerr<<C.at(x).at(y)+1<<endl;
break;
}
}
}
if(!flag){
break;
}
}
}
//cerr<<flag<<endl;
//if(flag){
ans++;
//}
printf("%lld\n",ans);
return 0;
}
harurun