結果
問題 | No.594 壊れた宝物発見機 |
ユーザー | uenoku |
提出日時 | 2017-11-10 23:57:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 106 ms / 2,000 ms |
コード長 | 2,582 bytes |
コンパイル時間 | 1,844 ms |
コンパイル使用メモリ | 181,252 KB |
実行使用メモリ | 25,232 KB |
平均クエリ数 | 97.60 |
最終ジャッジ日時 | 2024-07-16 14:38:35 |
合計ジャッジ時間 | 5,189 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function 'int solve()': main.cpp:90:105: warning: 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: warning: narrowing conversion of '(((lli)x[0][0]) + i)' from 'lli' {aka 'long long int'} to 'int' [-Wnarrowing] main.cpp:90:118: warning: 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: warning: narrowing conversion of '(((lli)x[1][0]) + j)' from 'lli' {aka 'long long int'} to 'int' [-Wnarrowing] main.cpp:90:131: warning: 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: warning: 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(); }