結果
| 問題 |
No.325 マンハッタン距離2
|
| コンテスト | |
| ユーザー |
lip_of_cygnus
|
| 提出日時 | 2016-02-07 09:06:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,248 bytes |
| コンパイル時間 | 585 ms |
| コンパイル使用メモリ | 68,228 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-21 20:58:01 |
| 合計ジャッジ時間 | 1,763 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 13 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define debug(X) cout<<"["<<#X<<"]"<<X<<endl;
#define debug2(X) cout<<X<<endl;
#define MAX_N 2010
#define MAX_M 3
const int INF=1e8;
typedef pair<int,int>P;
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// queue<P> que;
int a[4],k,L,H,d;
#include <deque>
int main(){
cin >>a[0]>>a[1]>>a[2]>>a[3]>>d;
int minT,maxT;
minT=min(abs(a[0]),abs(a[2]))+min(abs(a[1]),abs(a[3]));
//maxT=max(abs(a[0]),abs(a[2]))+max(abs(a[1]),abs(a[3]))-minT;
k=d-minT;
L=min((a[2]-a[0]),(a[3]-a[1]));
H=max((a[2]-a[0]),(a[3]-a[1]));
if (k<0){cout <<0<<endl;}
else if (L+H<k){cout <<(H+1)*(L+1)<<endl;}
else if (0<=k && k<L){cout <<(k+1)*(k+2)/2<<endl;}
else if (L<=k&& k<=H){cout <<L*(L+1)/2+(L+1)*(k-L+1)<<endl;}
else if (H<k && k<=L+H){cout <<(H+1)*(L+1)-(L+H-k)*(L+H-k+1)/2<<endl;}
}
lip_of_cygnus