結果

問題 No.3120 Lower Nim
ユーザー hiikunZ
提出日時 2025-04-18 22:45:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,606 bytes
コンパイル時間 2,567 ms
コンパイル使用メモリ 216,416 KB
実行使用メモリ 25,972 KB
平均クエリ数 1721.30
最終ジャッジ日時 2025-04-18 22:45:36
合計ジャッジ時間 10,914 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other AC * 25 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
constexpr ll MAX = 2000000000000000000;
constexpr ld PI = 3.14159265358979;
constexpr ll MOD = 0;//2024948111;
ld dotorad(ld K){ return PI * K / 180.0; }
ld radtodo(ld K){ return K * 180.0 / PI; }
mt19937 mt;
void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); }
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }
    ll s = 0;
    for(ll i = 0;i < N;i++) s ^= A[i];
    ll p = 0;
    if(s == 0){
        cout << "Second" << endl;
        p = 1;
    }
    else{
        cout << "First" << endl;
    }
    while(1){
        if(p == 1){
            ll i,p;
            cin >> i >> p;
            i--;
            s ^= A[i];
            A[i] -= p;
            s ^= A[i];
        }
        else{
            ll id = -1,x = MAX;
            for(ll i = 0;i < N;i++){
                ll disired_nokori = (A[i] ^ s);
                if(disired_nokori < A[i]){
                    ll kesu = A[i] - disired_nokori;
                    if(kesu < x){
                        x = kesu;
                        id = i;
                    }
                }
            }

            cout << id + 1 << " " << x << endl;
            A[id] -= x;
            s = 0;
        }
        ll ret;
        cin >> ret;
        if(ret != 0) return 0;
        p ^= 1;
    }
}
0