Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
140561 陈志轩 抄近路 C++ 通过 100 9 MS 9108 KB 730 2024-03-30 15:53:35

Tests(9/9):


#include<bits/stdc++.h> #define int long long using namespace std; double dp[1005][1005]; bool f[1005][1005]; signed main(){ //freopen("a.txt","r",stdin); int n,m,k; cin>>n>>m>>k; for (int i = 1;i <= k;i++){ int x,y; cin>>x>>y; f[x][y] = true; } for (int i = 0;i <= n + 1;i++){ for (int j = 0;j <= m + 1;j++){ dp[i][j] = 200000007.0; } } dp[1][1] = 0.0; for (int i = 1;i <= n + 1;i++){ for (int j = 1;j <= m + 1;j++){ if (i == 1 && j == 1){ continue; } dp[i][j] = min(dp[i - 1][j],dp[i][j - 1]) + 100.0; if (f[i - 1][j - 1]){ dp[i][j] = min(dp[i][j],dp[i - 1][j - 1] + sqrt(20000.0)); } } } cout<<(long long)(dp[n + 1][m + 1] + 0.5); return 0; }


测评信息: