Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include<cmath>
- using namespace std;
- struct point{
- int x,y;
- };
- int main(){
- int N,M,diagnum = 0;
- cin >> N >> M;
- double ans = (N+M)*100;
- int num;
- cin >> num;
- vector< point > diag(num);
- for(int i = 0; i < num; ++i){
- cin >> diag[i].x >> diag[i].y;
- --diag[i].x;
- --diag[i].y;
- }
- point CurPos;
- CurPos.x = 0, CurPos.y = 0;
- while(CurPos.x != N && CurPos.y != M){
- bool exists = false;
- int minim = 1e9,minnum;
- for(int i = 0; i < num; ++i){
- if((diag[i].x != -1) && (diag[i].y != -1) && (diag[i].x >= CurPos.x) && (diag[i].y >= CurPos.y) && ((diag[i].x - CurPos.x + diag[i].y - CurPos.y) < minim)){
- minnum = i;
- minim = diag[i].x - CurPos.x + diag[i].y - CurPos.y;
- exists = true;
- }
- }
- if(exists){
- CurPos.x = diag[minnum].x+1;
- CurPos.y = diag[minnum].y+1;
- diag[minnum].x = diag[minnum].y = - 1;
- ++diagnum;
- }
- else{
- CurPos.x = N;
- CurPos.y = M;
- }
- }
- ans-=diagnum*100*(2 - sqrt(2.0));
- double intpart;
- ans = (modf (ans , &intpart) >= 0.5 ? ceil(ans) : floor(ans));
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement