Submission #1444564


Source Code Expand

// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
// clang-format on

main {
  int h, w;
  cin >> h >> w;
  vvi a(h, vi(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  vvi dp(h, vi(w));
  fn<int(int, int, int)> dfs = [&](int i, int j, int p) {
    if (i < 0 || j < 0 || i >= h || j >= w || a[i][j] >= p) return 0LL;
    if (dp[i][j]) return dp[i][j];
    int c = 0;
    vi di = {1, 0, -1, 0}, dj = {0, -1, 0, 1};
    rep(k, 4) c += dfs(i + di[k], j + dj[k], a[i][j]);
    return dp[i][j] = c + 1;
  };
  int c = 0;
  rep(i, h) rep(j, w) c += dfs(i, j, INF);
  cout << c << endl;
}

Submission Info

Submission Time
Task D - 経路
User AyaMorisawa
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1770 Byte
Status WA
Exec Time 513 ms
Memory 16128 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 2
AC × 21
WA × 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 WA 320 ms 16000 KB
01.txt WA 403 ms 16128 KB
02.txt AC 247 ms 15872 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 2 ms 256 KB
11.txt AC 512 ms 16000 KB
12.txt AC 513 ms 16000 KB
13.txt AC 512 ms 16000 KB
14.txt AC 512 ms 16000 KB
15.txt WA 446 ms 16000 KB
16.txt AC 511 ms 16000 KB
17.txt AC 512 ms 16000 KB
18.txt AC 266 ms 16000 KB
19.txt AC 247 ms 16000 KB
sample01.txt AC 1 ms 256 KB
sample02.txt AC 1 ms 256 KB