結果

問題 No.697 池の数はいくつか
ユーザー gazellegazelle
提出日時 2018-06-09 17:40:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,240 bytes
コンパイル時間 1,038 ms
コンパイル使用メモリ 125,412 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-04 05:14:36
合計ジャッジ時間 8,121 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

ll h,w;
vector<vector<int>> a(3000);
ll dx[]={1,0,-1,0};
ll dy[]={0,1,0,-1};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>h>>w;
	REP(i,h) REP(j,w) {
		ll hoge;
		cin>>hoge;
		a[i][j]=hoge;
	}
	ll sum=0;
	REP(i,h) REP(j,w) {
		if(a[i][j]) {
			bool d=true;
			REP(k,4) {
				ll nx=i+dx[k];
				ll ny=j+dy[k];
				if(nx>=0&&nx<h&&ny>=0&&ny<w&&a[nx][ny]==-1) d=false;
			}
			if(d) {
				a[i][j]=-1;
				sum++;
			}
		}
	}
	cout<<sum<<endl;
}
0