Submission #1127077


Source Code Expand

#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<sstream>
#include<math.h>
#include <iomanip>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define VB vector<bool>
#define VPLL vector<pair<ll,ll> >
#define VVL vector<vector<ll> >
#define VVVL vector<vector<vector<ll> > >
#define VVB vector<vector<bool> >
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1145141919810
#define PI 3.141592653589793238
#define vmin(vec) *std::min_element(vec.begin(),vec.end())
#define vmax(vec) *std::max_element(vec.begin(),vec.end())
#define vsum(vec) std::accumulate(vec.begin(),vec.end(),0LL)
#define ksort(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define ssort(vec) (vec.begin(),vec.end())
#define VPLLsort(vec) sort(vec.begin(), vec.end(),[](PLL &a, PLL &b){ return a.first < b.first; });
#define LTS(n) to_string(n)
#define STL(str) stoll(str)
using namespace std;

ll h, w, mod = 1e9 + 7;
VL dtate{ -1, 0, 1, 0 };
VL dyoko{ 0, 1, 0, -1 };

bool out(ll tate, ll yoko){
	return !(0 <= tate && tate < h && 0 <= yoko && yoko < w);
}

ll dfs(VVL &a, ll i, ll j){
	ll temp;
	temp = 0;
	rep(k, 4) if (!out(i + dtate[k], j + dyoko[k]) && a[i][j]<a[i + dtate[k]][j + dyoko[k]]) temp=temp+dfs(a,i+dtate[k],j+dyoko[k])+1;
	return temp;
}
 
int main() {
	cin >> h >> w;
	ll sum=1, temp;
	VVL a(h, VL(w, 0)); rep(i, h) rep(j, w) cin >> a[i][j];
	VVL count(h, VL(w, 1));
	VVB table(h, VB(w, false));
	rep(i, h) rep(j, w){
		sum = (sum + dfs(a, i, j))%mod;
	}cout << (sum + h*w)%mod -1<< endl;
	return 0;
}

Submission Info

Submission Time
Task D - 経路
User untan
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1780 Byte
Status TLE
Exec Time 2104 ms
Memory 16512 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 2
AC × 21
TLE × 3
Set Name Test Cases
sample sample01.txt, sample02.txt
All 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample01.txt, sample02.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
00.txt TLE 2104 ms 16384 KB
01.txt TLE 2104 ms 16512 KB
02.txt AC 218 ms 16128 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 1 ms 256 KB
06.txt AC 2 ms 256 KB
07.txt AC 2 ms 256 KB
08.txt AC 1 ms 256 KB
09.txt AC 1 ms 256 KB
10.txt AC 3 ms 256 KB
11.txt AC 596 ms 16128 KB
12.txt AC 595 ms 16128 KB
13.txt AC 596 ms 16128 KB
14.txt AC 597 ms 16128 KB
15.txt TLE 2104 ms 16256 KB
16.txt AC 596 ms 16128 KB
17.txt AC 597 ms 16128 KB
18.txt AC 200 ms 16128 KB
19.txt AC 179 ms 16128 KB
sample01.txt AC 1 ms 256 KB
sample02.txt AC 1 ms 256 KB