QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501185 | #5153. Delft Distance | Abcl | WA | 0ms | 4044kb | C++14 | 1.3kb | 2024-08-02 15:27:27 | 2024-08-02 15:27:28 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
const double hu=3.14159265358*10/4.0;
int h,w;
string s[705];
double ans[1410][1410];
void solve(){
cin>>h>>w;
for(int i=1;i<=h;i++){
cin>>s[i];
s[i]=' '+s[i];
}
for(int i=0;i<=h*2+5;i++){
for(int j=0;j<=w*2+5;j++){
ans[i][j]=1e9;
}
}
ans[0][0]=0;
for(int i=0;i<=h;i++){
for(int j=0;j<=w;j++){
for(int k1=0;k1<=1;k1++){
for(int k2=0;k2<=1;k2++){
int x=i*2+k1,y=j*2+k2;
if(x%2==1&&y%2==1)continue;
if(x>=1)
ans[x][y]=min(ans[x][y],ans[x-1][y]+5);
if(y>=1)
ans[x][y]=min(ans[x][y],ans[x][y-1]+5);
if(x%2==1&&y%2==0&&x>=1&&y>=1){
if((s[i+1][j]=='O')){
ans[x][y]=min(ans[x][y],ans[x-1][y-1]+hu);
}
}
if(x%2==0&&y%2==1&&x>=1&&y>=1){
if(s[i][j+1]=='O'||s[i+1][j+1]=='O'){
ans[x][y]=min(ans[x][y],ans[x-1][y-1]+hu);
}
}
// cout<<"i "<<i<<" j "<<j<<" "<<"x: "<<x<<" y "<<y<<" "<<ans[x][y]<<endl;
}
}
}
}
printf("%.10lf",ans[2*h][2*w]);
return;
}
signed main() {
// ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T_case=1;
// cin>>T_case;
while(T_case--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3920kb
input:
3 5 XOOXO OXOXO XXXXO
output:
71.4159265358
result:
ok found '71.4159265', expected '71.4159265', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
1 4 XOOX
output:
45.7079632679
result:
ok found '45.7079633', expected '45.7079633', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
1 1 X
output:
20.0000000000
result:
ok found '20.0000000', expected '20.0000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 4044kb
input:
1 1 O
output:
17.8539816339
result:
ok found '17.8539816', expected '17.8539816', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
1 3 XOO
output:
35.7079632679
result:
ok found '35.7079633', expected '35.7079633', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
1 5 OXOOO
output:
55.7079632679
result:
ok found '55.7079633', expected '55.7079633', error '0.0000000'
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3796kb
input:
6 10 XXXXXOOOOX XXOOOOOOOO XXXOXOOXOX OXOXOXXOOX OOXXOXXXXO OXOXXOOXOO
output:
140.6858347056
result:
wrong answer 1st numbers differ - expected: '142.8318531', found: '140.6858347', error = '0.0150248'