結果
| 問題 | 
                            No.208 王将
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-05-15 23:02:51 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 671 bytes | 
| コンパイル時間 | 206 ms | 
| コンパイル使用メモリ | 34,656 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-06 04:13:27 | 
| 合計ジャッジ時間 | 833 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 19 WA * 4 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |   scanf("%d%d%d%d", &x, &y, &x2, &y2);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <algorithm>
using namespace std;
int sign(int n) { return (n>0) - (n<0); }
int main(void) {
  int x, y, x2, y2;
  int res;
  scanf("%d%d%d%d", &x, &y, &x2, &y2);
  if(y==0 && y2==0 && sign(x)==sign(x2) && abs(x)>abs(x2)) { res = abs(x); }
  else if(x==0 && x2==0 && sign(y)==sign(y2) && abs(y)>abs(y2)) { res = abs(y); }
//  else if(x==0 || x2==0 || y==0||y2==0) { res=max(abs(x), abs(y)); }
  else if(x==y && x2==y2 && sign(x)==sign(x2) && abs(x)>abs(x2)) { res = abs(x) + 3; }
  else if(x==-y && x2==-y2 && sign(x)==sign(x2) && abs(x)>abs(x2)) { res = abs(x) + 3; }
  else { res = max(abs(x), abs(y)); }
  printf("%d\n", res);
  return 0;
}