結果
問題 | No.594 壊れた宝物発見機 |
ユーザー | uenoku |
提出日時 | 2017-11-10 23:57:23 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 117 ms / 2,000 ms |
コード長 | 2,582 bytes |
コンパイル時間 | 2,095 ms |
コンパイル使用メモリ | 178,268 KB |
実行使用メモリ | 24,372 KB |
平均クエリ数 | 97.60 |
最終ジャッジ日時 | 2023-09-23 14:59:03 |
合計ジャッジ時間 | 5,264 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 117 ms
24,084 KB |
testcase_01 | AC | 108 ms
23,568 KB |
testcase_02 | AC | 107 ms
23,712 KB |
testcase_03 | AC | 104 ms
24,060 KB |
testcase_04 | AC | 105 ms
24,072 KB |
testcase_05 | AC | 104 ms
23,568 KB |
testcase_06 | AC | 110 ms
23,820 KB |
testcase_07 | AC | 106 ms
23,892 KB |
testcase_08 | AC | 109 ms
24,372 KB |
testcase_09 | AC | 111 ms
23,400 KB |
testcase_10 | AC | 104 ms
23,700 KB |
testcase_11 | AC | 115 ms
23,688 KB |
testcase_12 | AC | 109 ms
23,520 KB |
testcase_13 | AC | 101 ms
23,424 KB |
testcase_14 | AC | 102 ms
23,664 KB |
testcase_15 | AC | 100 ms
23,664 KB |
testcase_16 | AC | 103 ms
23,532 KB |
testcase_17 | AC | 102 ms
23,448 KB |
testcase_18 | AC | 104 ms
24,372 KB |
testcase_19 | AC | 103 ms
23,676 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int solve()’ 内: main.cpp:90:105: 警告: narrowing conversion of ‘(((lli)x[0][0]) + i)’ from ‘lli’ {aka ‘long long int’} to ‘int’ [-Wnarrowing] 90 | ans.push_back(make_pair(ask(x[0][0] + i, x[1][0] + j, x[2][0] + k), vector<int>{x[0][0] + i, x[1][0] + j, x[2][0] + k})); | ~~~~~~~~^~~ main.cpp:90:105: 警告: narrowing conversion of ‘(((lli)x[0][0]) + i)’ from ‘lli’ {aka ‘long long int’} to ‘int’ [-Wnarrowing] main.cpp:90:118: 警告: narrowing conversion of ‘(((lli)x[1][0]) + j)’ from ‘lli’ {aka ‘long long int’} to ‘int’ [-Wnarrowing] 90 | ans.push_back(make_pair(ask(x[0][0] + i, x[1][0] + j, x[2][0] + k), vector<int>{x[0][0] + i, x[1][0] + j, x[2][0] + k})); | ~~~~~~~~^~~ main.cpp:90:118: 警告: narrowing conversion of ‘(((lli)x[1][0]) + j)’ from ‘lli’ {aka ‘long long int’} to ‘int’ [-Wnarrowing] main.cpp:90:131: 警告: narrowing conversion of ‘(((lli)x[2][0]) + k)’ from ‘lli’ {aka ‘long long int’} to ‘int’ [-Wnarrowing] 90 | ans.push_back(make_pair(ask(x[0][0] + i, x[1][0] + j, x[2][0] + k), vector<int>{x[0][0] + i, x[1][0] + j, x[2][0] + k})); | ~~~~~~~~^~~ main.cpp:90:131: 警告: narrowing conversion of ‘(((lli)x[2][0]) + k)’ from ‘lli’ {aka ‘long long int’} to ‘int’ [-Wnarrowing]
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (lli i = 0; i < (n); i++) #define rrep(i, n) for (lli i = (n)-1; i >= 0; i--) using namespace std; using lli = long long int; //#define DEBUG // 質問クエリ int ax = 34, ay = 45, az = -40; int solve(); void test() { solve(); } int ask(int x, int y, int z) { int d; #ifdef DEBUG return abs(x - ax) * 1000 + abs(y - ay) * 10 + abs(z - az); #endif cout << "?" << " " << x << " " << y << " " << z << endl; cin >> d; return d; } // 回答クエリ void answer(int x, int y, int z) { #ifdef DEBUG bool f = (x == ax and y == ay and z == az); if (!f) { cout << "NG" << ax << ":" << x << " " << ay << ":" << y << " " << az << ":" << z << endl; ; } return; #endif cout << "!" << " " << x << " " << y << " " << z << endl; } int solve(void) { int x[3][2] = {{-100, 100}, {-100, 100}, {-100, 100}}; while (abs(x[0][1] - x[0][0]) > 2) { int h = ask((2 * x[0][0] + x[0][1]) / 3, x[1][0], x[2][0]); int g = ask((x[0][0] + 2 * x[0][1]) / 3, x[1][0], x[2][0]); if (h < g) { x[0][1] = (x[0][0] + 2 * x[0][1]) / 3; } else { x[0][0] = (x[0][0] * 2 + x[0][1]) / 3; } } while (abs(x[1][1] - x[1][0]) > 2) { //int sita = ask(x[1][0], x[1][0], x[2][0]); //int ue = ask(x[1][1], x[1][0], x[2][0]); int h = ask(x[0][0], (2 * x[1][0] + x[1][1]) / 3, x[2][0]); int g = ask(x[0][0], (x[1][0] + 2 * x[1][1]) / 3, x[2][0]); if (h < g) { x[1][1] = (x[1][0] + 2 * x[1][1]) / 3; } else { x[1][0] = (x[1][0] * 2 + x[1][1]) / 3; } } while (abs(x[2][1] - x[2][0]) > 2) { //int sita = ask(x[2][0], x[1][0], x[2][0]); //int ue = ask(x[2][1], x[1][0], x[2][0]); int h = ask(x[0][0], x[1][0], (2 * x[2][0] + x[2][1]) / 3); int g = ask(x[0][0], x[1][0], (x[2][0] + 2 * x[2][1]) / 3); if (h < g) { x[2][1] = (x[2][0] + 2 * x[2][1]) / 3; } else { x[2][0] = (x[2][0] * 2 + x[2][1]) / 3; } } vector<pair<int, vector<int>>> ans; rep(i, 3) { rep(j, 3) { rep(k, 3) { ans.push_back(make_pair(ask(x[0][0] + i, x[1][0] + j, x[2][0] + k), vector<int>{x[0][0] + i, x[1][0] + j, x[2][0] + k})); } } } sort(ans.begin(), ans.end()); auto h = ans[0].second; answer(h[0], h[1], h[2]); return 0; } int main() { test(); }