結果
問題 |
No.602 隠されていたゲーム2
|
ユーザー |
|
提出日時 | 2017-12-17 16:40:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,418 bytes |
コンパイル時間 | 991 ms |
コンパイル使用メモリ | 67,052 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-12-15 22:36:38 |
合計ジャッジ時間 | 18,160 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 2 TLE * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%d", &d[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:23:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf("%d %d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <map> #include <vector> #include <algorithm> #include <iostream> using namespace std; #define PRINT(x) { std::cout << #x << ": " << x << std::endl; } //#define PRINT(x) int main(int argc, char *argv[]) { int n; scanf("%d", &n); vector<int> d(n); for (int i = 0; i < n; ++i) { scanf("%d", &d[i]); } int x, y; scanf("%d %d", &x, &y); if (x == 0 && y == 0) { puts("0"); return 0; } int D = abs(x) + abs(y); vector<int>::iterator it = find(d.begin(), d.end(), D); if (it != d.end()) { puts("1"); return 0; } bool ok = false; for (int i = 0; i < n; ++i) { int dmin, dmax; if (D - d[i] > 0) { dmin = D - d[i]; dmax = dmin + 2 * d[i]; } else { dmin = d[i] - D; dmax = dmin + 2 * D; } for (int j = i + 1; j < n; ++j) { int dd = d[j] - dmin; if (dd < 0) continue; if (dd % 2 == 1) continue; if (dmax - d[j] < 0) continue; ok = true; i = n; break; } } if (ok) { puts("2"); } else { puts("-1"); } return 0; }