結果

問題 No.2726 Rooted Tree Nim
ユーザー makichan
提出日時 2025-02-21 01:12:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,203 bytes
コンパイル時間 7,037 ms
コンパイル使用メモリ 332,988 KB
実行使用メモリ 16,160 KB
最終ジャッジ日時 2025-02-21 01:12:21
合計ジャッジ時間 10,105 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<(int)n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};


void test(){
    vector<vector<int>> G(200,vector<int>(200));
    rep(i,0,100)rep(j,0,100-i){
        vector<bool> b(1000);
        rep(k,1,min(i+1,4))b[G[i-k][j+k]]=true;
        rep(k,1,min(j+1,4))b[G[i][j-k]]=true;
        while(b[G[i][j]])G[i][j]++;
    }
    rep(i,0,10){
        rep(j,0,10)cout << G[i][j] << " ";
        cout << "\n";
    }
}

void solve(){
    int n,k;cin >> n >> k;
    vector<vector<int>> G(n);
    rep(i,1,n){
        int a,b;cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        swap(a,b);
        G[a].push_back(b);
    }
    vector<int> a(n);
    rep(i,0,n)cin >> a[i];
    int g=0;
    for(auto x:G[0])g^=a[x]%(k+1);
    if(g)cout << "K\n";
    else cout << "P\n";
}
int main(){
    // test();

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;cin >> T;
    rep(i,0,T)solve();
}
0