Submission #30293421


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

std::vector<std::string> split(const std::string& text, const char delim);

using ll = long long int;
using llu = unsigned long long int;

enum class Player : int {
    T = 0,
    A = 1,
};

int main(){
    string buffer;
    getline(cin, buffer);
    const int N = stoi(buffer);

    list<int> number_list;
    for (int i = 0; i < N * 2 + 1; ++i) {
        number_list.emplace_back(i + 1);
    }

    int turn_player = static_cast<int>(Player::T);

    while (true) {
        if (turn_player == static_cast<int>(Player::T)) {
            const int number = *number_list.begin();
            number_list.erase(number_list.begin());
            cout << number << endl << flush;
        } else {
            getline(cin, buffer);
            const int number = stoi(buffer);
            if (number == 0) {
                return 0;
            }
            auto target_it = std::find(number_list.begin(), number_list.end(), number);
            number_list.erase(target_it);
        }
        turn_player = 1 - turn_player;
    }

    return 0;
}

std::vector<std::string> split(const std::string& text, const char delim) {
    std::vector<std::string> item_list;
    std::stringstream ss(text);
    std::string buffer;

    while ( std::getline(ss, buffer, delim) ) {
        if (!buffer.empty()) {
                item_list.emplace_back(buffer);
        }
    }

    return item_list;
}

Submission Info

Submission Time
Task C - Yamanote Line Game
User low10603
Language C++ (GCC 9.2.1)
Score 300
Code Size 1541 Byte
Status AC
Exec Time 33 ms
Memory 3784 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 15
Set Name Test Cases
Sample example0.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, example0.txt
Case Name Status Exec Time Memory
000.txt AC 33 ms 3656 KiB
001.txt AC 22 ms 3708 KiB
002.txt AC 23 ms 3784 KiB
003.txt AC 20 ms 3716 KiB
004.txt AC 7 ms 3640 KiB
005.txt AC 21 ms 3628 KiB
006.txt AC 23 ms 3772 KiB
007.txt AC 18 ms 3736 KiB
008.txt AC 10 ms 3756 KiB
009.txt AC 20 ms 3708 KiB
010.txt AC 22 ms 3568 KiB
011.txt AC 24 ms 3692 KiB
012.txt AC 22 ms 3688 KiB
013.txt AC 27 ms 3780 KiB
example0.txt AC 6 ms 3696 KiB