結果

問題 No.208 王将
ユーザー 158b
提出日時 2015-05-16 00:09:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 938 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 61,184 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-09 16:22:16
合計ジャッジ時間 1,187 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
using namespace std;


int main(){
	int goal[2];
	int teki[2];
	int goal_h[2];
	int teki_h[2];
	int adjust = 0;
	
	cin >> goal[0] >> goal[1] >> teki[0] >> teki[1];
	
	//斜め
	if(abs(goal[0]) == abs(goal[1]) && abs(teki[0]) == abs(teki[1]) ){
		//符号調査
		for(int i=0; i<2; i++){
			if(goal[i] == 0){
				goal_h[i] = 0;
			}else if(goal[i] < 0){
				goal_h[i] = -1;
			}else{
				goal_h[i] = 1;
			}
		}
		for(int i=0; i<2; i++){
			if(teki[i] == 0){
				teki_h[i] = 0;
			}else if(teki[i] < 0){
				teki_h[i] = -1;
			}else{
				teki_h[i] = 1;
			}
		}
		
		
		//斜め
		if(goal_h[0] == teki_h[0] && goal_h[1] == teki_h[1] && abs(teki[0]) < abs(goal[0]) && abs(teki[1]) < abs(goal[1])){
			adjust = 1;
		}else{
			adjust = 0;
		}
	}else{
		adjust = 0;
	}
	
	cout << max(abs(goal[0]), abs(goal[1])) + adjust << endl;
	return 0;
}
0