結果

問題 No.208 王将
ユーザー kkslucy1
提出日時 2018-03-12 23:14:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,010 bytes
コンパイル時間 1,963 ms
コンパイル使用メモリ 159,424 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-15 18:12:32
合計ジャッジ時間 2,275 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	int x, y, x2, y2;
	cin >> x >> y >> x2 >> y2;
	int ans = 0;
	if (x == 0) {
		if (x2 == 0) {
			if (y>0&&y2>0&&y<y2||y<0&&y2<0&&y>y2) {
				ans = abs(y);
			}
			else {
				ans = abs(y) + 1;
			}
		}
		else {
			ans = abs(y);
		}
	}else if (y == 0) {
		if (y2 == 0) {
			if (x>0 && x2>0 && x<x2 || x<0 && x2<0 && x>x2) {
				ans = abs(x);
			}
			else {
				ans = abs(x) + 1;
			}
		}
		else {
			ans = abs(x);
		}
	}
	else if (x == y && x2 == y2) {
		if (x > 0 && x2 > 0 && x < x2 || x < 0 && x2<0 && x>x2) {
			ans = abs(x);
		}
		else {
			ans = abs(x) + 1;
		}
	}
	else if (x == -y && x2 == -y2) {
		if (x > 0 && x2 > 0) {
			if (x < x2) {
				ans = abs(x);
			}
			else {
				ans = abs(x) + 1;
			}

		}
		else if (x < 0 && x2 < 0) {
			if (x > x2) {
				ans = abs(x);
			}
			else {
				ans = abs(x) + 1;
			}
		}
		else {
			ans = abs(x);
		}
	}
	else {
		ans = max(abs(x), abs(y));
	}
	cout << ans << endl;

	return 0;
}
0