Conan and Agasa play a Card Game

time limit per test:2 seconds
memory limit per test:256 megabytes
input:standard input
output:standard output

Problem Description

Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.

They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all cards having a number strictly lesser than the number on the chosen card. Formally, if the player chooses the i-th card, he removes that card and removes the j-th card for all j such that aj < ai.

A player loses if he cannot make a move on his turn, that is, he loses if there are no cards left. Predict the outcome of the game, assuming both players play optimally.

Input

The first line contains an integer n (1 ≤ n ≤ 10^5) — the number of cards Conan has.

The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 10^5), where ai is the number on the i-th card.

Output

If Conan wins, print "Conan" (without quotes), otherwise print "Agasa" (without quotes).

Sample Input

3
4 5 7
2
1 1

Sample Output

Conan
Agasa


http://codeforces.com/contest...

Accepted Code

// Author : Weihao Long
// Created : 2018/01/21

#include <bits/stdc++.h>

using namespace std;

const int maxn = 100007;

int card[maxn];

bool cmp(int a, int b) {
    return a > b;
}

int main() {
    int n;
    cin >> n;
    int value;
    for (int i = 0; i < n; i++) {
        cin >> value;
        card[value]++;
    }
    bool flag = false;
    sort(card, card + maxn, cmp);
    for (int i = 0; i < n; i++) {
        if (card[i] % 2) {
            flag = true;
            break;
        }
    }
    if (flag)
        cout << "Conan" << endl;
    else
        cout << "Agasa" << endl;
    return 0;
}

Notes

题意:
有 n 张卡牌,每张牌上都有一个数字。柯南和博士轮流操作:“选取一张牌,把牌面数字小于此牌的所有卡牌丢弃,然后把这张卡牌也丢弃”。到最后谁不能操作谁就输了。柯南先手。

思路:
统计各数字出现的次数,如果有奇数次的则柯南赢,否则博士赢。


龙威昊
4 声望5 粉丝