Contest Duration: - (local time) (90 minutes) Back to Home

Submission #18716

Source Code Expand

Copy
```#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

class C{
struct Node{
int next;
int sec;
double cost;
Node(int n,int s,double c):next(n),sec(s),cost(c){}
bool operator<(const Node &n)const{
return cost<n.cost;
}
};
int N,M;
vector<string> field;
bool isValid(int y,int x){
return y>=0 && y<N && x>=0 && x<M;
}
public:
bool init(){
if(scanf("%d%d",&N,&M)==EOF)return false;
field.resize(N);
REP(i,N){
char buf[1024];
scanf("%s",buf);
field[i] = string(buf);
}
return true;
}
void solve(){
int sy,sx,gy,gx;
REP(y,N)REP(x,M){
if(field[y][x]=='s'){
sy = y;
sx = x;
}
if(field[y][x]=='g'){
gy = y;
gx = x;
}
}
vector<double> pre(N*M,1);
REP(i,N*M-1)pre[i+1] = pre[i]*0.99;
vector<vector<double> > used(N,vector<double>(M,-2));
priority_queue<Node> que;que.push(Node(sy*M+sx,0,100));
while(!que.empty()){
Node n = que.top();que.pop();
int cy = n.next/M;
int cx = n.next%M;
if(used[cy][cx]>-1)continue;
used[cy][cx] = n.cost;

const int DY[] = {-1,0,1,0};
const int DX[] = {0,1,0,-1};
REP(i,4){
int ny = cy+DY[i];
int nx = cx+DX[i];
if(isValid(ny,nx) && used[ny][nx]<-1 && field[ny][nx]!='#'){
double cost = field[ny][nx]-'0';
cost *= pre[n.sec+1];
if(field[ny][nx]=='g')cost = n.cost;
que.push(Node(ny*M+nx,n.sec+1,min(n.cost,cost)));
}
}
}
if(used[gy][gx]<-1)printf("-1\n");
else printf("%.9f\n",used[gy][gx]);
}
};

int main(){
C solver;
while(solver.init()){
solver.solve();
}
return 0;
}```

#### Submission Info

Submission Time 2012-05-27 20:29:38+0900 C - 暗闇帰り道 nel215 C++ (G++ 4.6.4) 0 2014 Byte WA 220 ms 7152 KB

#### Compile Error

```./Main.cpp: In member function ‘bool C::init()’:
./Main.cpp:45:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
```

#### Judge Result

Set Name all
Score / Max Score 0 / 100
Status
 AC × 21 WA × 43
Set Name Test Cases
all 00_mini_01.txt, 00_mini_02.txt, 00_mini_03.txt, 00_mini_04.txt, 00_mini_05.txt, 00_sample_01.txt, 00_sample_02.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 01_rnd_20.txt, 02_maxrnd_01.txt, 02_maxrnd_02.txt, 02_maxrnd_03.txt, 02_maxrnd_04.txt, 02_maxrnd_05.txt, 02_maxrnd_06.txt, 02_maxrnd_07.txt, 02_maxrnd_08.txt, 02_maxrnd_09.txt, 02_maxrnd_10.txt, 02_maxrnd_11.txt, 02_maxrnd_12.txt, 02_maxrnd_13.txt, 02_maxrnd_14.txt, 02_maxrnd_15.txt, 02_maxrnd_16.txt, 02_maxrnd_17.txt, 02_maxrnd_18.txt, 02_maxrnd_19.txt, 03_hard_01.txt, 03_hard_02.txt, 03_hard_03.txt, 03_hard_04.txt, 03_hard_05.txt, 03_hard_06.txt, 03_hard_07.txt, 03_hard_08.txt, 04_open_01.txt, 04_open_02.txt, 05_minihard_01.txt, 05_minihard_02.txt, 05_minihard_03.txt, 05_minihard_04.txt, 05_minihard_05.txt, 05_minihard_06.txt, 05_minihard_07.txt, 05_minihard_08.txt
Case Name Status Exec Time Memory
00_mini_01.txt AC 21 ms 764 KB
00_mini_02.txt AC 22 ms 792 KB
00_mini_03.txt AC 20 ms 792 KB
00_mini_04.txt AC 21 ms 788 KB
00_mini_05.txt AC 20 ms 792 KB
00_sample_01.txt AC 22 ms 792 KB
00_sample_02.txt AC 21 ms 796 KB
01_rnd_01.txt WA 172 ms 5108 KB
01_rnd_02.txt WA 82 ms 2944 KB
01_rnd_03.txt WA 35 ms 1400 KB
01_rnd_04.txt WA 39 ms 1660 KB
01_rnd_05.txt WA 25 ms 1040 KB
01_rnd_06.txt WA 22 ms 920 KB
01_rnd_07.txt WA 31 ms 1304 KB
01_rnd_08.txt WA 75 ms 3056 KB
01_rnd_09.txt WA 100 ms 3956 KB
01_rnd_10.txt WA 83 ms 3580 KB
01_rnd_11.txt WA 57 ms 2684 KB
01_rnd_12.txt WA 44 ms 2020 KB
01_rnd_13.txt WA 24 ms 1044 KB
01_rnd_14.txt WA 67 ms 3316 KB
01_rnd_15.txt WA 47 ms 2428 KB
01_rnd_16.txt AC 34 ms 1840 KB
01_rnd_17.txt AC 36 ms 2300 KB
01_rnd_18.txt AC 22 ms 924 KB
01_rnd_19.txt AC 24 ms 1560 KB
01_rnd_20.txt AC 22 ms 1016 KB
02_maxrnd_01.txt WA 215 ms 6124 KB
02_maxrnd_02.txt WA 204 ms 6144 KB
02_maxrnd_03.txt WA 183 ms 6128 KB
02_maxrnd_04.txt WA 181 ms 6128 KB
02_maxrnd_05.txt WA 179 ms 5616 KB
02_maxrnd_06.txt WA 164 ms 5596 KB
02_maxrnd_07.txt WA 155 ms 5612 KB
02_maxrnd_08.txt WA 165 ms 5616 KB
02_maxrnd_09.txt WA 146 ms 5612 KB
02_maxrnd_10.txt WA 136 ms 5364 KB
02_maxrnd_11.txt WA 131 ms 5620 KB
02_maxrnd_12.txt WA 127 ms 5364 KB
02_maxrnd_13.txt WA 116 ms 5380 KB
02_maxrnd_14.txt WA 115 ms 5116 KB
02_maxrnd_15.txt WA 99 ms 5108 KB
02_maxrnd_16.txt WA 90 ms 4980 KB
02_maxrnd_17.txt WA 72 ms 4988 KB
02_maxrnd_18.txt AC 47 ms 4988 KB
02_maxrnd_19.txt AC 47 ms 4992 KB
03_hard_01.txt WA 191 ms 7152 KB
03_hard_02.txt WA 190 ms 7148 KB
03_hard_03.txt AC 67 ms 4984 KB
03_hard_04.txt AC 69 ms 4988 KB
03_hard_05.txt WA 186 ms 6120 KB
03_hard_06.txt WA 186 ms 6132 KB
03_hard_07.txt AC 69 ms 4984 KB
03_hard_08.txt AC 69 ms 4984 KB
04_open_01.txt AC 121 ms 4988 KB
04_open_02.txt WA 220 ms 6136 KB
05_minihard_01.txt WA 23 ms 784 KB
05_minihard_02.txt WA 23 ms 788 KB
05_minihard_03.txt AC 20 ms 808 KB
05_minihard_04.txt AC 20 ms 788 KB
05_minihard_05.txt WA 24 ms 784 KB
05_minihard_06.txt WA 22 ms 792 KB
05_minihard_07.txt WA 22 ms 784 KB
05_minihard_08.txt WA 21 ms 792 KB