Submission #1748684


Source Code Expand

#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int h,w,a[1010][1010];
map<int,pair<int,int>> mp;

int main(){
	cin >> h >> w;
	REP(i,0,h+2) REP(j,0,w+2) a[i][j]=INF;
	REP(i,0,h) REP(j,0,w) cin >> a[i+1][j+1],mp[a[i+1][j+1]]=make_pair(i+1,j+1);
	
	int c=0,v[]={1,0,-1,0,1},li[1010][1010]={};
	REP(i,1,h*w+1){
		int pos=0;
		REP(j,0,4){
			int x=mp[i].first+v[j], y=mp[i].second+v[j+1];
			if(a[x][y]<i){
				if(!pos) pos=li[x][y];
				else if(pos!=li[x][y]) pos=-1;
			}
		}
		if(pos) li[mp[i].first][mp[i].second]=pos;
		else li[mp[i].first][mp[i].second]=i;
		if(pos==-1) c++;
	}
	
	cout << c << endl;
	return 0;
}

Submission Info

Submission Time
Task E - 尾根 (Ridge)
User ecasdqina
Language C++14 (GCC 5.4.1)
Score 100
Code Size 903 Byte
Status AC
Exec Time 1829 ms
Memory 72704 KB

Judge Result

Set Name set01 set02 set03 set04 set05
Score / Max Score 20 / 20 20 / 20 20 / 20 20 / 20 20 / 20
Status
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
Set Name Test Cases
set01 data1
set02 data2
set03 data3
set04 data4
set05 data5
Case Name Status Exec Time Memory
data1 AC 5 ms 4608 KB
data2 AC 1829 ms 70656 KB
data3 AC 1474 ms 70528 KB
data4 AC 1509 ms 70656 KB
data5 AC 1238 ms 72704 KB