HDU 5301 Buildings (亂搞)

解析:首先使得矩陣的n<=m,然後將矩陣對稱處理,使得(x,y)的位置位於右下。這樣一來只需要判斷(x-1,y)的處理以及完後的對應方案即可。

[code]:

include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

int n,m,x,y;

int main(){
    int i,j,cas,u,v;
    while(~scanf("%d%d%d%d",&n,&m,&x,&y)){
        if(n > m){
            swap(n,m);swap(x,y);
        }
        if(x <= (n+1)/2) x = n+1-x;
        if(y <= (m+1)/2) y = m+1-y;
        int tmp = min(m+1-y,x-1);
        int o1,o2;
        if(n&1){
            printf("%d\n",max(tmp,n/2+1-(n==m&&x==y&&x==n/2+1)));
        }else printf("%d\n",max(tmp,n/2));
    }

    return 0;
}


發佈了219 篇原創文章 · 獲贊 4 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章