#include <iostream> #include <vector> #include <cmath> using namespace std; vector<vector<double> > dp(1001,vector<double>(1001)); int main(){ int n,m,k; cin>>n>>m>>k; for(int i=0;i<k;i++){ int x,y; cin>>x>>y; dp[x][y]=1; } double inc=sqrt(2); dp[0][0]=0; for(int y=1;y<=m;y++) dp[0][y]=y; for(int x=1;x<=n;x++) dp[x][0]=x; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(round(dp[i][j])==1) dp[i][j]=min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+inc)); else dp[i][j]=1+min(dp[i-1][j],dp[i][j-1]); } } cout<<round(100*dp[n][m])<<endl; return 0; }
Comments
Post a Comment