結果
問題 |
No.2521 Don't be Same
|
ユーザー |
![]() |
提出日時 | 2024-06-19 22:55:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 1,238 bytes |
コンパイル時間 | 492 ms |
コンパイル使用メモリ | 40,832 KB |
最終ジャッジ日時 | 2025-02-21 23:23:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int read(int&, int&)’: main.cpp:15:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%s", op); | ~~~~~^~~~~~~~~~ main.cpp:18:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | if (op[0] == 'A') scanf("%d%d", &i, &z), i--; | ~~~~~^~~~~~~~~~~~~~~~ main.cpp: In function ‘int main()’: main.cpp:26:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d%d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 2521.cc: No.2521 Don't be Same - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* subroutines */ int read(int &i, int &z) { char op[4]; scanf("%s", op); i = z = -1; if (op[0] == 'A') scanf("%d%d", &i, &z), i--; return op[0] - 'A'; } /* main */ int main() { int x, y; scanf("%d%d", &x, &y); if (((x & 1) && y == x + 1) || ((y & 1) && x == y + 1)) { puts("Second"); fflush(stdout); int i, z; int r = read(i, z); if (r >= 2) return 0; if (i == 0) x -= z; else y -= z; } else { puts("First"); fflush(stdout); } while (x > 0 || y > 0) { if (x == y) { puts("B"); x = y = 0; } else if (x == 0) { printf("A 2 %d\n", y); y = 0; } else if (y == 0) { printf("A 1 %d\n", x); x = 0; } else if (x < y) { int z = (x & 1) ? y - (x + 1) : y - (x - 1); printf("A 2 %d\n", z); y -= z; } else { // x > y int z = (y & 1) ? x - (y + 1) : x - (y - 1); printf("A 1 %d\n", z); x -= z; } fflush(stdout); int i, z; int r = read(i, z); if (r >= 2) break; if (i == 0) x -= z; else y -= z; } return 0; }