結果

問題 No.1852 Divide or Reduce
ユーザー milanis48663220milanis48663220
提出日時 2022-02-25 22:09:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 1,929 bytes
コンパイル時間 1,094 ms
コンパイル使用メモリ 117,792 KB
実行使用メモリ 4,956 KB
最終ジャッジ日時 2023-09-16 17:08:58
合計ジャッジ時間 5,893 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 88 ms
4,376 KB
testcase_02 AC 88 ms
4,376 KB
testcase_03 AC 90 ms
4,380 KB
testcase_04 AC 88 ms
4,376 KB
testcase_05 AC 88 ms
4,376 KB
testcase_06 AC 62 ms
4,380 KB
testcase_07 AC 62 ms
4,600 KB
testcase_08 AC 61 ms
4,628 KB
testcase_09 AC 61 ms
4,376 KB
testcase_10 AC 61 ms
4,688 KB
testcase_11 AC 62 ms
4,916 KB
testcase_12 AC 62 ms
4,920 KB
testcase_13 AC 61 ms
4,956 KB
testcase_14 AC 62 ms
4,908 KB
testcase_15 AC 62 ms
4,908 KB
testcase_16 AC 338 ms
4,620 KB
testcase_17 AC 350 ms
4,544 KB
testcase_18 AC 334 ms
4,680 KB
testcase_19 AC 301 ms
4,628 KB
testcase_20 AC 332 ms
4,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

void solve(){
    int n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll a_sum = accumulate(a.begin(), a.end(), 0ll);
    ll a_min = *min_element(a.begin(), a.end());
    if(a_min == 1){
        if((a_sum-n)%2 == 1) cout << "First" << endl;
        else cout << "Second" << endl;
        return;
    }
    if((a_sum-n)%2 == 1) {
        cout << "First" << endl;
        return;
    }
    if(n%2 == 1){
        cout << "Second" << endl;
        return;
    }
    if((a_min-1)%2 == 1){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int t; cin >> t;
    while(t--) solve();
}
0