|
|
back to boardCan someone help me with test 8? Posted by DKarev 26 Jun 2013 22:30 I have WA on test 8. Can someone help. I tried every given test in the site but I can't find any mistakes. This is my code: // #include<iostream> #include<cmath> #include<algorithm> #include<iomanip> using namespace std; bool b[2005][2005]; long double a[2005][2005]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); long double diag=sqrt(2)*100; int n,m,k,k1,r; cin>>n>>m>>r; for(int i=0;i<r;i++) { cin>>k>>k1; b[k][k1]=1; } n++; m++; for(int i=2;i<=n;i++)a[1][i]=a[1][i-1]+100; for(int i=2;i<=n;i++) { for(int j=1;j<=m;j++) { a[i][j]=a[i-1][j]+100; if(j!=1 && a[i][j]>a[i][j-1]+100)a[i][j]=a[i][j-1]+100; if(b[i-1][j-1] && a[i][j]>a[i-1][j-1]+diag+0.001)a[i][j]=a[i-1][j-1]+diag; } } cout<<fixed<<setprecision(0)<<a[n][m]<<"\n"; return 0; } |
|
|