QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#363715#1644. Reverse Gamemoeezm#AC ✓1ms3812kbC++14863b2024-03-24 02:18:332024-03-24 02:18:34

Judging History

This is the latest submission verdict.

  • [2024-03-24 02:18:34]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 3812kb
  • [2024-03-24 02:18:33]
  • Submitted

answer

#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    // int n = 50;
    // vector<bool> dp(n); // first player win or loss? 1 is win 0 is loss
    // dp[0] = 0;
    // for (int i = 0; i < n; i++) {
    //     if (i > 0) dp[i] = dp[i] || !dp[i-1];
    //     if (i > 1) dp[i] = dp[i] || !dp[i-2];
    // }
    // for (int i = 0; i < n; i++) {
    //     cout << i << ' ' << dp[i] << endl;
    // }
    vector<bool> win = {0, 1, 1, 0, 1, 1};
    ll cnt = 0;
    ll su = 0;
    string s; cin >> s;
    int n = s.length();
    for (int i = 1; i <= n; i++) {
        cnt += (s[n-i] == '1');
        su += i*(s[n-i] == '1');
    }
    // cout << "CNT: " << cnt << endl;
    // cout << "SUM: " << su << endl;
    ll x = cnt*(cnt+1)/2;
    su -= x;
    cout << (win[su%6] ? "Alice" : "Bob");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3476kb

input:

010

output:

Alice

result:

ok single line: 'Alice'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

1111

output:

Bob

result:

ok single line: 'Bob'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

1010

output:

Bob

result:

ok single line: 'Bob'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

1010001011001

output:

Alice

result:

ok single line: 'Alice'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

0

output:

Bob

result:

ok single line: 'Bob'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

01

output:

Bob

result:

ok single line: 'Bob'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

000

output:

Bob

result:

ok single line: 'Bob'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

0000

output:

Bob

result:

ok single line: 'Bob'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

00000

output:

Bob

result:

ok single line: 'Bob'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

011110

output:

Alice

result:

ok single line: 'Alice'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

0111111

output:

Bob

result:

ok single line: 'Bob'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

00000000

output:

Bob

result:

ok single line: 'Bob'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

000001100

output:

Alice

result:

ok single line: 'Alice'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

1100010011

output:

Bob

result:

ok single line: 'Bob'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

10100110110

output:

Bob

result:

ok single line: 'Bob'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

101010100101

output:

Alice

result:

ok single line: 'Alice'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

1011110000110

output:

Alice

result:

ok single line: 'Alice'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

11010010101111

output:

Alice

result:

ok single line: 'Alice'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

110001101000101

output:

Alice

result:

ok single line: 'Alice'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

1100110000001101

output:

Alice

result:

ok single line: 'Alice'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

10101010010010101

output:

Alice

result:

ok single line: 'Alice'

Test #22:

score: 0
Accepted
time: 1ms
memory: 3508kb

input:

101111001111000110

output:

Alice

result:

ok single line: 'Alice'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

1111000011110110000

output:

Alice

result:

ok single line: 'Alice'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

11011111111011100100

output:

Bob

result:

ok single line: 'Bob'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

11000000001111010011100101100001001010100011110010110010100000111010000001101111000010110011110

output:

Alice

result:

ok single line: 'Alice'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

111101001100101010101010110100001000110110011110110100100110110101001010000110010000001101110010

output:

Bob

result:

ok single line: 'Bob'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

1011101001000101101000010110001000101100011000101001101110000010001100001001011110001010101001001

output:

Alice

result:

ok single line: 'Alice'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

10101000011001100111000010111111111110101100100010000111011001001001001100110001101000001000100011

output:

Alice

result:

ok single line: 'Alice'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

110001001111000101101111000011110101011100111000111011101001101001111001100101110110100101010110101

output:

Alice

result:

ok single line: 'Alice'