欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

agc002E - Candy Piles(博弈论)

程序员文章站 2022-04-28 11:11:00
题意 "题目链接" Sol "Orz SovitPower" ......

题意

sol

orz sovitpower

#include<bits/stdc++.h> 
#define pair pair<int, double>
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long 
#define ll long long 
#define fin(x) {freopen(#x".in","r",stdin);}
#define fout(x) {freopen(#x".out","w",stdout);}
using namespace std;
const int maxn = 1e6 + 10, mod = 998244353, inf = 2e9 + 10;
const double eps = 1e-9;
template <typename a, typename b> inline bool chmin(a &a, b b){if(a > b) {a = b; return 1;} return 0;}
template <typename a, typename b> inline bool chmax(a &a, b b){if(a < b) {a = b; return 1;} return 0;}
template <typename a, typename b> inline ll add(a x, b y) {if(x + y < 0) return x + y + mod; return x + y >= mod ? x + y - mod : x + y;}
template <typename a, typename b> inline void add2(a &x, b y) {if(x + y < 0) x = x + y + mod; else x = (x + y >= mod ? x + y - mod : x + y);}
template <typename a, typename b> inline ll mul(a x, b y) {return 1ll * x * y % mod;}
template <typename a, typename b> inline void mul2(a &x, b y) {x = (1ll * x * y % mod + mod) % mod;}
template <typename a> inline void debug(a a){cout << a << '\n';}
template <typename a> inline ll sqr(a x){return 1ll * x * x;}
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int n, a[maxn];
signed main() {
    n = read();
    for(int i = 1; i <= n; i++) a[i] = read();
    sort(a + 1, a + n + 1, greater<int>());
    for(int i = 1; i <= n; i++) {
        if(i + 1 > a[i + 1]) {
            if((a[i] - i) & 1) {puts("first"); return 0;}
            int j;
            for(j = i + 1; a[j] == i; j++); 
            if(!((j - i) & 1)) {puts("first"); return 0;}
            puts("second"); return 0;
        }
    }
    return 0;
}