結果

問題 No.3018 目隠し宝探し
ユーザー vwxyz
提出日時 2025-01-25 14:20:09
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 5,421 bytes
コンパイル時間 3,115 ms
コンパイル使用メモリ 277,460 KB
実行使用メモリ 87,208 KB
平均クエリ数 0.05
最終ジャッジ日時 2025-01-25 23:17:21
合計ジャッジ時間 70,298 ms
ジャッジサーバーID
(参考情報)
judge10 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 1
other AC * 1 TLE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
using pil=pair<int,long long>;
using pli=pair<int,int>;
using pll=pair<long long,long long>;

template<class T>
using vvector=vector<vector<T>>;
template<class T>
using vvvector=vector<vvector<T>>;
template<class T>
using vvvvector=vector<vvvector<T>>;

#define Vector(type, name, ...) vector<type> name(__VA_ARGS__)
#define VVector(type, name, h, ...) \
    vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define VVVector(type, name, h, w, ...) \
    vector<vector<vector<type>>> name( \
        h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define VVVVector(type, name, a, b, c, ...) \
    vector<vector<vector<vector<type>>>> name( \
        a, vector<vector<vector<type>>>( \
            b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

#define OVERLOAD_REP(_1, _2, _3, _4, name, ...) name
#define REP1(n) for (int _ = 0; _ < (int)(n); _++)
#define REP2(i,n) for (int i = 0; i < (int)(n); i++)
#define REP3(i,l,r) for (int i = (int)(l); i < (int)(r); i++)
#define REP4(i,l,r,d) for (int i = (int)(l); (int)(d) > 0 ? i < (int)(r) : i > (int)(r); i += (int)(d))
#define rep(...) OVERLOAD_REP(__VA_ARGS__,REP4,REP3,REP2,REP1)(__VA_ARGS__)

#define OVERLOAD_REPll(_1, _2, _3, _4, name, ...) name
#define REP1ll(n) for (ll _ = 0; _ < (ll)(n); _++)
#define REP2ll(i,n) for (ll i = 0; i < (ll)(n); i++)
#define REP3ll(i,l,r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define REP4ll(i,l,r,d) for (ll i = (ll)(l); (ll)(d) > 0 ? i < (ll)(r) : i > (ll)(r); i += (ll)(d))
#define repll(...) OVERLOAD_REPll(__VA_ARGS__,REP4ll,REP3ll,REP2ll,REP1ll)(__VA_ARGS__)

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

template<class T>
void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T>
void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}

ostream &operator<<(ostream &os, const __int128_t &N) {
    string retu="";
    if(N==0){
        retu="0";
    }
    else{
        __int128_t NN=N;
        if(NN<0){
            retu+='-';
            NN=-NN;
        }
        for(;NN>0;NN/=10){
            retu+=(char)(NN%10)+'0';
        }
        reverse(retu.begin(),retu.end());
    }
    os<<retu;
    return os;
}

template<class T1,class T2>
ostream &operator<< (ostream &os, pair<T1,T2> &p){
    if(&os==&cerr){return os << "(" << p.first << ", " << p.second << ")";}
    return os << p.first << " " << p.second;
}

template <class Ch,class Tr,class Container> basic_ostream<Ch,Tr> &operator<<(basic_ostream<Ch,Tr> &os, const Container &x) {
    bool first=true;
    if(&os==&cerr){os<<"[";}
    for(auto &y:x){
        if(&os==&cerr){os<<(first?"":", ")<<y;}
        else{os<<(first?"":" ")<<y;}
        first=false;
    }
    if(&os==&cerr){os<<"]";}
    return os;
}

template <class T, class S, class U> ostream &operator<<(ostream &os, const priority_queue<T, S, U> &pq) {
    auto _pq = pq;
    vector<T> retu;
    while(!empty(_pq)) retu.emplace_back(_pq.top()), _pq.pop();
    return os << retu;
}

namespace aux {
    template <class T, unsigned N, unsigned L> struct tp {
        static void output(ostream &os, const T &v) {
            os << get<N>(v) << (&os == &cerr ? ", " : " ");
            tp<T, N + 1, L>::output(os, v);
        }
    };
    template <class T, unsigned N> struct tp<T, N, N> {
        static void output(ostream &os, const T &v) { os << get<N>(v); }
    };
}
template <class... Ts> ostream &operator<<(ostream &os, const tuple<Ts...> &t) {
    if(&os == &cerr) { os << '('; }
    aux::tp<tuple<Ts...>, 0, sizeof...(Ts) - 1>::output(os, t);
    if(&os == &cerr) { os << ')'; }
    return os;
}


template <class Container,class T> Container operator+(Container x,T v) {
    for(auto &y:x){
        y=y+v;
    }
    return x;
}

template <class Container,class T> Container &operator+=(Container &x,T v) {
    for(auto &y:x){
        y+=v;
    }
    return x;
}

string Yes(bool bl){
    return bl?"Yes":"No";
};

string No(bool bl){
    return Yes(!bl);
};

string YES(bool bl){
    return bl?"YES":"NO";
};

string NO(bool bl){
    return YES(!bl);
};


long long pow_mod(long long x,long long n,long long mod){
    if(n==0){
        return 1LL;
    }
    if(n%2==0){
        long long p=pow_mod(x,n/2,mod);
        return p*p%mod;
    }
    else{
        long long p=pow_mod(x,n/2,mod);
        p*=p;
        p%=mod;
        p*=x;
        return p%mod;
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H,W;cin>>H>>W;
    if(H==1&&W==1){
        cout<<"!"<<" "<<1<<" "<<1<<"\n";
        exit(0);
    }
    else if(H==1||W==1){
        cout<<"?"<<" "<<1<<" "<<1<<"\n";
        int d;cin>>d;
        rep(h,H){
            rep(w,W){
                if(h*h+w*w==d){
                    cout<<"!"<<" "<<h+1<<" "<<w+1<<"\n";
                    exit(0);
                }
            }
        }
    }
    else{
        cout<<"?"<<" "<<1<<" "<<1<<"\n";
        int d0;cin>>d0;
        cout<<"?"<<" "<<1<<" "<<2<<"\n";
        int d1;cin>>d1;
        rep(h,H){
            rep(w,W){
                if(h*h+w*w==d0&&h*h+(w-1)*(w-1)==d1){
                    cout<<"!"<<" "<<h+1<<" "<<w+1<<"\n";
                    exit(0);
                }
            }
        }
    }
}
0