Submission #723051
Source Code Expand
#include <stdio.h>
#define MAX 1002
#define MOD ((unsigned long long)(1e9+7))
unsigned int a[MAX][MAX];
unsigned long long point[MAX][MAX];
unsigned long long search(int x,int y){
unsigned long long pointsum=1;
if(point[x][y]>0)return point[x][y];
if(a[x][y] < a[x+1][y] ){
pointsum += search(x+1,y);
}
if(a[x][y] < a[x-1][y] ){
pointsum += search(x-1,y);
}
if(a[x][y] < a[x][y+1] ){
pointsum += search(x,y+1);
}
if(a[x][y] < a[x][y-1] ){
pointsum += search(x,y-1);
}
point[x][y]=pointsum % MOD;
return pointsum;
}
int main(){
int ret;
int H,W;
int i,j,k;
unsigned long long int llret=0;
for(i=0;i<MAX;i++){
for(j=0;j<MAX;j++){
a[i][j]=0;
point[i][j]=0;
}
}
ret=scanf("%d %d",&H,&W);
for(i=1;i<=H;i++){
for(j=1;j<=W;j++){
ret=scanf("%d",&a[i][j]);
}
}
for(i=1;i<=H;i++){
for(j=1;j<=W;j++){
search(i,j);
}
}
for(i=1;i<=H;i++){
for(j=1;j<=W;j++){
llret += point[i][j];
llret = llret % MOD;
}
}
printf("%lld\n",llret);
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - 経路 |
| User | yab |
| Language | C (GCC 5.4.1) |
| Score | 100 |
| Code Size | 1325 Byte |
| Status | AC |
| Exec Time | 298 ms |
| Memory | 12032 KiB |
Judge Result
| Set Name | sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 100 / 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00.txt | AC | 213 ms | 12032 KiB |
| 01.txt | AC | 235 ms | 12032 KiB |
| 02.txt | AC | 183 ms | 11904 KiB |
| 03.txt | AC | 23 ms | 11904 KiB |
| 04.txt | AC | 20 ms | 11904 KiB |
| 05.txt | AC | 22 ms | 11904 KiB |
| 06.txt | AC | 20 ms | 11904 KiB |
| 07.txt | AC | 20 ms | 11904 KiB |
| 08.txt | AC | 20 ms | 11904 KiB |
| 09.txt | AC | 20 ms | 11904 KiB |
| 10.txt | AC | 20 ms | 11904 KiB |
| 11.txt | AC | 295 ms | 11904 KiB |
| 12.txt | AC | 295 ms | 11904 KiB |
| 13.txt | AC | 296 ms | 11904 KiB |
| 14.txt | AC | 295 ms | 11904 KiB |
| 15.txt | AC | 259 ms | 12032 KiB |
| 16.txt | AC | 298 ms | 11904 KiB |
| 17.txt | AC | 298 ms | 11904 KiB |
| 18.txt | AC | 199 ms | 11904 KiB |
| 19.txt | AC | 175 ms | 11904 KiB |
| sample01.txt | AC | 20 ms | 11904 KiB |
| sample02.txt | AC | 22 ms | 11904 KiB |