Submission #1370589
Source Code Expand
#include <iostream> #include <stack> #include <map> #include <cstdio> using namespace std; typedef long long ll; typedef pair<int, int> P; const int N = 1e+9 + 7; int a[1010][1010]; int dx[]={1, 0, -1, 0}; int dy[]={0, 1, 0, -1}; ll bfs(int x, int y) { stack<P> next; P current; next.push(P(x, y)); ll cnt=1; while (!next.empty()) { current = next.top(); next.pop(); for (int i=0; i<4; i++) { int nx = current.first + dx[i]; int ny = current.second + dy[i]; if (a[current.first][current.second] < a[nx][ny]) { cnt++; next.push(P(nx, ny)); } } } return cnt; } int main() { int H, W; cin >> H >> W; for (int i=0; i<H+2; i++) { for (int j=0; j<W+2; j++) { a[i][j] = 0; } } for (int i=1; i<H+1; i++) { for (int j=1; j<W+1; j++) { scanf("%d", a[i] + j); } } ll ans=0; for (int i=1; i<H+1; i++) { for (int j=1; j<W+1; j++) { ans += bfs(i, j); ans %= N; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 経路 |
User | university |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1102 Byte |
Status | TLE |
Exec Time | 2104 ms |
Memory | 12304 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:48:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", a[i] + j); ^
Judge Result
Set Name | sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||
Status |
|
|
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 | 2103 ms | 4224 KB |
01.txt | TLE | 2104 ms | 12304 KB |
02.txt | AC | 375 ms | 4224 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 | 384 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 3 ms | 384 KB |
11.txt | AC | 526 ms | 4224 KB |
12.txt | AC | 525 ms | 4224 KB |
13.txt | AC | 525 ms | 4224 KB |
14.txt | AC | 527 ms | 4224 KB |
15.txt | TLE | 2103 ms | 4224 KB |
16.txt | AC | 526 ms | 4224 KB |
17.txt | AC | 528 ms | 4224 KB |
18.txt | AC | 350 ms | 4224 KB |
19.txt | AC | 323 ms | 4224 KB |
sample01.txt | AC | 1 ms | 256 KB |
sample02.txt | AC | 1 ms | 256 KB |