結果

問題 No.3598 Queen vs. King
コンテスト
ユーザー nosu kuro
提出日時 2026-07-24 22:26:25
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 4,956 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,035 ms
コンパイル使用メモリ 332,260 KB
実行使用メモリ 6,016 KB
平均クエリ数 2.17
最終ジャッジ日時 2026-07-24 22:26:35
合計ジャッジ時間 3,259 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#ifndef INCLUDED_MAIN
#define INCLUDED_MAIN

#include __FILE__

using namespace nskr;
using mint = modint<0>;

int main(void){
    int t; cin >> t;
    int h, w; cin >> h >> w;

    int x, y;
    cin >> x >> y;
    if(x == h){
        cout << h-1 << " " << 1 << endl;
        cin >> x >> y;
        cout << h-1 << " " << y << endl;
    }else if(y == w){
        cout << 1 << " " << w-1 << endl;
        cin  >> x >> y;
        cout << x << " " << w-1 << endl;
    }else if(h==3){
        cout << 1 << " " << w-2 << endl;
        cin >>x >> y;
        if(x == h && y == w){
            cout << 2 << " " << w-2 << endl;
        }else if(x == h){
            cout << x-1 << " " << y-1 << endl;
            cin >> x >> y;
            cout << 2 << " " << w-1 << endl;
        }else{
            cout << 1 << " " << w-1 << endl;
            cin >> x >> y;
            cout << 2 << " " << w-1 << endl;        
        }
    }else if(w==3){
        cout << h-2 <<" " << 1 << endl;
        cin >> x >> y;
        if(x==h&&y==w){
            cout << h-2 << " " << 2 << endl;
        } else if(y == w){
            cout << x-1 << " " << y-1 << endl;
            cin >> x >> y;
            cout << h-1 << 2 << endl;
        }else{
            cout << h-1 << " " << 1 << endl;
            cin >> x >> y;
            cout << h-1 << " "  << 2 << endl;
        }
    }else{
        cout << h-2 << " " << 1 << endl;
        cin >>x >> y;
        if(x == h && y == w){
            cout << h-2 << " " << w-1 << endl;
        }else if(y == w){
            cout << x-1 << " " << y-1 << endl;
            cin >> x >> y;
            cout << h-1 << " " << w-1 << endl;
        }else{
            cout << h-2 << " " << w-2 << endl;
            cin >> x >> y;
            cout << h-1 << " " << w-1 << endl;        
        }
    }
    cin >> x >> y;
}




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

using ll = long long;
using ld = long double;
#define rep(i,n) for(i=0;i<(n);i++)
#define all(a) a.begin(), a.end()

namespace nskr{

    //nyaan氏の実装をかなり参考にした
    template <int id = 0>
    struct modint{
        int v;

        static int& MOD(){
            static int mod = 998244353;
            return mod;
        }

        static int get_mod() { return MOD(); }
        static void set_mod(int m) { MOD() = m; }

        modint() :v(0){}
        modint(long long x) : v( (x>=0 ? x%MOD() : (x%MOD() + MOD()))){}

        long long val() const {return v;}

        modint& operator+=(const modint& x){if((v+=x.v) >= MOD()) v-=MOD(); return *this; }
        modint& operator-=(const modint& x){if((v-=x.v) <  0  ) v+=MOD(); return *this; }
        modint& operator*=(const modint& x){v = (int)(1ll * v * x.v % MOD()); return *this;}
        modint& operator/=(const modint& x){v = (int)(1ll * v * x.inv().val() % MOD()); return *this;}

        modint operator-() const {return modint(-v);}
        modint operator+() const {return *this;}

        modint operator+(const modint& x) const {return modint(*this)+=x;}
        modint operator-(const modint& x) const {return modint(*this)-=x;}
        modint operator*(const modint& x) const {return modint(*this)*=x;}
        modint operator/(const modint& x) const {return modint(*this)/=x;}

        bool operator== (const modint& x) const {return v==x.v;}
        bool operator!= (const modint& x) const {return v!=x.v;}

        friend ostream &operator<<(ostream &os, const modint &p) { return os << p.v; }

        friend istream &operator>>(istream &is, modint &a) {
            int t;
            is >> t;
            a = modint<id>(t);
            return (is);
        }


        modint pow(unsigned long long n) const { 
            modint ret(1), mul(v);
            while(n){
                if(n&1) ret *= mul;
                mul *= mul;
                n >>=1;
            }
            return ret;
        }

        modint inv() const{ //参考: https://qiita.com/sesame0224/items/f2ac77c367f588c0d29d
            int a = v, b = MOD(), u = 1, w = 0;
            while(b){
                int t = a/b;                 
                swap(a -= t*b, b);
                swap(u -= t*w, w);
            }
            u%=MOD();
            return(u<0?u+MOD():u);
        }


    };

    template<typename mint>
    struct combination{
        vector<mint> fac;
        combination():fac({mint(1)}){}
        
        void preculc(int n){
            fac.reserve(n);
            while(fac.size() <= n){
                fac.push_back( (*fac.rbegin()) * mint(fac.size()) );
            }
            return;
        }

        mint comb(int n, int r){ 
            if(r>n || r<0 || n<0) return 0;
            if(n-r < r) r = n-r;
            if(fac.size() > n) return fac[n] * fac[r].inv() * fac[n-r].inv();
            else{
                mint ret = fac[r].inv();
                for(;r--;) ret *= (n-r+1);
                return ret;
            }
        }
    };
}



#endif
0