結果

問題 No.601 Midpoint Erase
ユーザー exteloextelo
提出日時 2017-12-15 14:35:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,093 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 28,672 KB
最終ジャッジ日時 2025-01-05 05:31:14
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:43:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   43 |   scanf("%lld", &num);
      |   ~~~~~^~~~~~~~~~~~~~
main.cpp:49:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |     scanf("%lld %lld", &point[i].x, &point[i].y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

typedef long long int lli;

class Point
{
public:
  lli x;
  lli y;
};

int divide(Point *point, lli num)
{
  lli even_even = 0;
  lli even_odd = 0;
  lli odd_even= 0;
  lli odd_odd = 0;

  for (int i=0; i<num; i++) {
    if (point[i].x % 2 == 0 && point[i].y % 2 == 0) {
      even_even++;
    } 
    if (point[i].x % 2 == 0 && point[i].y % 2 != 0) {
      even_odd++;
    }
    if (point[i].x % 2 != 0 && point[i].y % 2 == 0) {
      odd_even++;
    }
    if (point[i].x % 2 !=0 && point[i].y % 2 != 0) {
      odd_odd++;
    }
  }
// %4 ==0||1 winner is Bob, else Alice 
  lli judge = ((even_even / 2) + (even_odd / 2) + (odd_even / 2) + (odd_odd / 2)) % 2;
  
  return judge;
}


int main(void)
{
  lli num;
  scanf("%lld", &num);

  Point *point;
  point = new Point[num];

  for (int i=0; i<num; i++) {
    scanf("%lld %lld", &point[i].x, &point[i].y);
  //  printf("%lld %lld\n", point[i].x, point[i].y);
  }

  int winner;
  winner = divide(point, num);

  if (winner == 0) {
    printf("Bob\n");
  }
  if (winner == 1) {
    printf("Alice\n");
  }

  return 0;
}

0