# Metro

http://acm.timus.ru/problem.aspx?space=1&num=1119

Many of SKB Kontur programmers like to get to work by Metro because the main office is situated quite close the station Uralmash. So, since a sedentary life requires active exercises off-duty, many of the staff — Nikifor among them — walk from their homes to Metro stations on foot.
Nikifor lives in a part of our city where streets form a grid of residential quarters. All the quarters are squares with side 100 meters. A Metro entrance is situated at one of the crossroads. Nikifor starts his way from another crossroad which is south and west of the Metro entrance. Naturally, Nikifor, starting from his home, walks along the streets leading either to the north or to the east. On his way he may cross some quarters diagonally from their south-western corners to the north-eastern ones. Thus, some of the routes are shorter than others. Nikifor wonders, how long is the shortest route.
You are to write a program that will calculate the length of the shortest route from the south-western corner of the grid to the north-eastern one.

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;

bool path[1010][1010];
double dp[1010][1010];
int main()
{
//freopen("in.txt", "r", stdin);
int m, n;
while (~scanf("%d %d",&n,&m))
{
memset(path, 0, sizeof(path));
int k, x, y;
scanf("%d", &k);
for (int i = 0; i < k; i++)
{
scanf("%d %d", &x, &y);
path[x][y] = true;
}
dp[0][0] = 0;
for (int i = 1; i < n + 1; i++)
dp[i][0] = dp[i - 1][0] + 1;
for (int i = 1; i < m + 1; i++)
dp[0][i] = dp[0][i-1] + 1;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m;j++)
{
if (path[i][j]==true)
{
dp[i][j] = min(dp[i - 1][j] + 1, min(dp[i][j - 1] + 1, dp[i - 1][j - 1] + sqrt(2.0f)));
}
else
dp[i][j] = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1);
}
printf("%.f", dp[n][m] * 100);

}
return 0;
}

• 本文已收录于以下专栏：

## 基于Bootstrap的Metro风格模板

• ys743276112
• 2015年06月02日 11:22
• 2877

## Metro UI CSS 学习笔记之一：简介和Metro UI CSS 环境搭建

• zhouzhiwengang
• 2015年01月23日 11:25
• 1808

## Android学习之 UI--Metro风格

Android 仿Windows Metro 界面UI - Android移动开发技术文章_手机开发 - 红黑联盟Android中View(视图)绘制不同状态背景图片原理深入分析以及StateList...
• abidepan
• 2014年12月10日 20:28
• 2538

## 酷！用Qt Quick实现Metro风格的进度条

• unixzii
• 2014年01月28日 22:58
• 3222

## 微软Metro风格颜色值

• Justme0
• 2012年12月22日 23:42
• 4203

## 一套配色完整的Metro风格PSD源文件

• wcs542882916
• 2015年03月05日 19:15
• 416

## 对Bootstrap Metro Dashboard进行改造

• tyutpanda
• 2017年08月18日 16:06
• 651

## Metro UI风格配色方案

Metro UI共提供10种配色方案。它们分别是： 红色：E51400 绿色：339933 蓝色：1BA1E2 橙色：F09609 草绿：8CBF26 ...
• wocaonima123987
• 2013年01月16日 16:13
• 1308

## Metro风格界面

Metro风格界面是Windows8代表性的亮点，Metro界面的脱颖而出似乎是一次大的颠覆，未来的Windows软件界面肯定会以Metro这种新兴设计风格成主流。        国外的UI设计师已...
• zhongguoren666
• 2011年11月22日 10:20
• 4178

## Metro风格用户界面设计原则

• qq542369628
• 2013年01月09日 22:01
• 764

举报原因： 您举报文章：Metro 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)