Submission #44110678


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
string s;
cin >> s;
vector<int> one, two;
for (int i = 0; i < n + 1; i++) {
if (s[i] == 'A') one.push_back(i);
else two.push_back(i);
}
int mex = 0;
set<int> st;
for (int i = 0; i < n; i++) {
if (i % 2 == 1) {
if (one.size() >= (i / 2 + 1)) st.insert(one[i / 2]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;

#define int long long

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> one, two;
    for (int i = 0; i < n + 1; i++) {
        if (s[i] == 'A') one.push_back(i);
        else two.push_back(i);
    }
    int mex = 0;
    set<int> st;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 1) {
            if (one.size() >= (i / 2 + 1)) st.insert(one[i / 2]);
            else {
                st.insert(two.back());
                two.pop_back();
            }
        }
        else {
            if (two.size() >= (i / 2 + 1)) st.insert(two[i / 2]);
            else {
                st.insert(one.back());
                one.pop_back();
            }
        }
        while (st.count(mex)) mex++;
        if (s[mex] == 'A') cout << "Alice\n";
        else cout << "Bob\n";
    }
}

Submission Info

Submission Time
Task A - Mex Game
User Sharky
Language C++ (GCC 9.2.1)
Score 300
Code Size 951 Byte
Status AC
Exec Time 110 ms
Memory 14448 KB

Compile Error

./Main.cpp: In function ‘int32_t main()’:
./Main.cpp:21:28: warning: comparison of integer expressions of different signedness: ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} and ‘long long int’ [-Wsign-compare]
   21 |             if (one.size() >= (i / 2 + 1)) st.insert(one[i / 2]);
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~~
./Main.cpp:28:28: warning: comparison of integer expressions of different signedness: ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} and ‘long long int’ [-Wsign-compare]
   28 |             if (two.size() >= (i / 2 + 1)) st.insert(two[i / 2]);
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 30
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 04_max_rand_01.txt, 04_max_rand_02.txt, 04_max_rand_03.txt, 04_max_rand_04.txt, 04_max_rand_05.txt, 05_half_half_01.txt, 05_half_half_02.txt, 05_half_half_03.txt, 05_half_half_04.txt, 05_half_half_05.txt, 06_hand_01.txt, 06_hand_02.txt, 06_hand_03.txt, 06_hand_04.txt, 06_hand_05.txt, 06_hand_06.txt, 06_hand_07.txt, 06_hand_08.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 7 ms 3436 KB
01_sample_02.txt AC 2 ms 3452 KB
01_sample_03.txt AC 2 ms 3576 KB
02_small_01.txt AC 2 ms 3536 KB
02_small_02.txt AC 2 ms 3588 KB
02_small_03.txt AC 2 ms 3564 KB
02_small_04.txt AC 2 ms 3512 KB
03_rand_01.txt AC 11 ms 4112 KB
03_rand_02.txt AC 45 ms 9612 KB
03_rand_03.txt AC 42 ms 8944 KB
03_rand_04.txt AC 61 ms 10740 KB
03_rand_05.txt AC 35 ms 7840 KB
04_max_rand_01.txt AC 96 ms 14340 KB
04_max_rand_02.txt AC 66 ms 14320 KB
04_max_rand_03.txt AC 98 ms 14316 KB
04_max_rand_04.txt AC 87 ms 14324 KB
04_max_rand_05.txt AC 85 ms 14448 KB
05_half_half_01.txt AC 88 ms 14300 KB
05_half_half_02.txt AC 99 ms 14224 KB
05_half_half_03.txt AC 103 ms 14360 KB
05_half_half_04.txt AC 94 ms 14384 KB
05_half_half_05.txt AC 110 ms 14332 KB
06_hand_01.txt AC 106 ms 14380 KB
06_hand_02.txt AC 100 ms 14324 KB
06_hand_03.txt AC 89 ms 14432 KB
06_hand_04.txt AC 99 ms 14404 KB
06_hand_05.txt AC 97 ms 14300 KB
06_hand_06.txt AC 99 ms 14228 KB
06_hand_07.txt AC 97 ms 14132 KB
06_hand_08.txt AC 93 ms 14188 KB


2025-03-05 (Wed)
12:29:35 +00:00