結果
問題 | No.2823 PEX (Predecessing Excluded Value) Game |
ユーザー |
![]() |
提出日時 | 2024-07-26 21:49:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 113 ms / 2,000 ms |
コード長 | 1,449 bytes |
コンパイル時間 | 2,131 ms |
コンパイル使用メモリ | 198,800 KB |
最終ジャッジ日時 | 2025-02-23 18:32:34 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }#define all(x) (x).begin(),(x).end()#define fi first#define se second#define mp make_pair#define si(x) int(x.size())const int mod=998244353,MAX=300005,INF=15<<26;int main(){std::ifstream in("text.txt");std::cin.rdbuf(in.rdbuf());cin.tie(0);ios::sync_with_stdio(false);ll N;cin>>N;vector<pair<ll,ll>> S(N),T;for(int i=0;i<N;i++) cin>>S[i].fi>>S[i].se;if(S[0].fi>1) T.push_back(mp(1,S[0].fi-1));for(int i=0;i+1<N;i++){if(S[i].se+1<S[i+1].fi) T.push_back(mp(S[i].se+1,S[i+1].fi-1));}T.push_back(mp(S.back().se+1,S.back().se+1));ll M=T.back().se;for(int i=0;i<si(T);i++){T[i].fi=M-T[i].fi;T[i].se=M-T[i].se;swap(T[i].fi,T[i].se);}reverse(all(T));ll cn=0;for(int i=0;i<si(T);i++){cn+=(T[i].se-T[i].fi+1);}if(cn&1) T[0].fi--;ll X=0;ll la=-1;cn=0;for(auto [a,b]:T){if(cn&1){X^=(a-la-1);cn++;a++;}cn+=(b-a+1);if(cn&1) la=b;}assert(cn%2==0);if(X) cout<<"First\n";else cout<<"Second\n";}