結果

問題 No.1429 Simple Dowsing
ユーザー norikamenorikame
提出日時 2021-03-14 14:55:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,881 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 204,948 KB
実行使用メモリ 24,372 KB
平均クエリ数 2.67
最終ジャッジ日時 2023-09-24 10:05:44
合計ジャッジ時間 4,042 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,376 KB
testcase_01 AC 23 ms
23,640 KB
testcase_02 AC 24 ms
23,340 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 24 ms
24,048 KB
testcase_06 RE -
testcase_07 WA -
testcase_08 AC 23 ms
23,640 KB
testcase_09 AC 26 ms
24,348 KB
testcase_10 AC 23 ms
23,664 KB
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 AC 23 ms
23,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
#define v(t) vector<t>
#define p(t) pair<t, t>
#define p2(t, s) pair<t, s>
#define vp(t) v(p(t))

#define rep(i, n) for (int i=0,i##_len=((int)(n)); i<i##_len; ++i)
#define rep2(i, a, n) for (int i=((int)(a)),i##_len=((int)(n)); i<=i##_len; ++i)
#define repr(i, n) for (int i=((int)(n)-1); i>=0; --i)
#define rep2r(i, a, n) for (int i=((int)(n)),i##_len=((int)(a)); i>=i##_len; --i)

#define repi(itr, c) for (__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); ++itr)
#define repir(itr, c) for (__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); ++itr)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define eb emplace_back

#define INF (1e9)
#define LINF (1e18)
#define PI (acos(-1))
#define EPS (1e-7)
#define DEPS (1e-10)

int main(){
    cout << "? " << 0 << ' ' << 0 << '\n';
    cout.flush();
    int d = 0;
    cin >> d;
    vp(int) a1, a2;
    rep(a, 51) rep2(b, a, 100) if (a*a+b*b==d) a1.eb(a,b);
    cout << "? " << 0 << ' ' << a1.front().second << '\n';
    cout.flush();
    cin >> d;
    rep(a, 51) rep2(b, a, 100) if (a*a+b*b==d) a2.eb(a,b);
    p(int) ans = {-1,-1}, pos = { 0, a1.front().second }, tar = a2.front();
    rep(i, sz(a1)) {
        if (a1[i].first==pos.first+tar.first && a1[i].second==pos.second-tar.second) {
            if (pos.first+tar.first>=0 && pos.first+tar.first<=100 && pos.second-tar.second>=0 && pos.second-tar.second<=100) ans = a1[i];
        }
        if (a1[i].first != a1[i].second) {
            if (a1[i].second==pos.first+tar.first && a1[i].first==pos.second-tar.second) {
                if (pos.first+tar.first>=0 && pos.first+tar.first<=100 && pos.second-tar.second>=0 && pos.second-tar.second<=100) ans = { a1[i].second, a1[i].first };
            }
        }
    }
    if (ans == (p(int)){-1,-1}) {
        swap(tar.first, tar.second);
        rep(i, sz(a1)) {
            if (a1[i].first==pos.first+tar.first && a1[i].second==pos.second-tar.second) {
                if (pos.first+tar.first>=0 && pos.first+tar.first<=100 && pos.second-tar.second>=0 && pos.second-tar.second<=100) ans = a1[i];
            }
            if (a1[i].first != a1[i].second) {
                if (a1[i].second==pos.first+tar.first && a1[i].first==pos.second-tar.second) {
                    if (pos.first+tar.first>=0 && pos.first+tar.first<=100 && pos.second-tar.second>=0 && pos.second-tar.second<=100) ans = { a1[i].second, a1[i].first };
                }
            }
        }
    }
    cout << "! " << ans.first << ' ' << ans.second << endl;
    return 0;
}
0