結果

問題 No.208 王将
ユーザー 158b158b
提出日時 2015-05-16 00:09:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 938 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 62,628 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-30 21:20:21
合計ジャッジ時間 1,537 ms
ジャッジサーバーID
(参考情報)
judge5 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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