QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#108313 | #4315. 简单的卡牌游戏 | Public123# | AC ✓ | 409ms | 28060kb | C++14 | 2.2kb | 2023-05-24 14:05:54 | 2023-05-24 14:05:55 |
Judging History
answer
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define PB emplace_back
// #define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) {rep(i, 0, siz(n) - 1) cout << n[i] << " \n"[i == siz(n) - 1];}
const int N = 2e7;
bool s[4][14];
int top;
int id(char x) {
if(x == 'S') return 0;
if(x == 'H') return 1;
if(x == 'D') return 2;
if(x == 'C') return 3;
assert(0);
}
bitset<1475789056> s1;
bitset<1475789056> s2;
int get(vi &st) {
int res = 0;
rep(i, 0, siz(st) - 1) res = res * 14 + st[i];
return res;
}
int dfs(vi &st, bool o) {
bool is = 1;
rep(i, 0, 3) is &= st[i * 2] == 1 && st[i * 2 + 1] == 13;
if(is) return 3;
int id = get(st);
if(s1[id] || s2[id]) return s1[id] * 2 + s2[id];
bool res = 0, q = 0;
rep(i, 0, 3) {
int l = st[i * 2], r = st[i * 2 + 1];
if(!l && !r) {
if(s[i][7] == o) {
vi t = st;
t[i * 2] = t[i * 2 + 1] = 7;
int tmp = dfs(t, o ^ 1);
q |= tmp == 3;
res |= tmp == 2;
}
}
if(l && l - 1 >= 1 && s[i][l - 1] == o) {
vi t = st;
--t[i * 2];
int tmp = dfs(t, o ^ 1);
q |= tmp == 3;
res |= tmp == 2;
}
if(r && r + 1 <= 13 && s[i][r + 1] == o) {
vi t = st;
++t[i * 2 + 1];
int tmp = dfs(t, o ^ 1);
q |= tmp == 3;
res |= tmp == 2;
}
}
if(!res) {
if(q) return s1[id] = s2[id] = 1, 3;
else return s1[id] = 1, 2;
}
return s2[id] = 1, 1;
}
signed main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
string x;
int y;
rep(i, 1, 26) {
cin >> x;
stringstream tin(x.substr(1, siz(x) - 1));
tin >> y;
s[id(x[0])][y] = 1;
}
vi st;
st.PB(7), st.PB(7);
rep(i, 1, 3) st.PB(0), st.PB(0);
int res = dfs(st, !s[0][7]);
if(res == 3) cout << "Draw";
else res & 1 == !s[0][7] ? cout << "Alice" : cout << "Bob";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 254ms
memory: 27116kb
input:
C12 S1 C7 H7 C3 D12 S5 C9 H4 S6 D10 H2 H1 S13 S10 C6 C10 H6 S7 D2 H3 D9 C13 D6 D4 H10
output:
Bob
result:
ok single line: 'Bob'
Test #2:
score: 0
Accepted
time: 200ms
memory: 28060kb
input:
C13 C7 C12 D11 D6 C2 D10 H1 H12 H2 S9 S10 D7 C3 H6 C6 S5 C5 D4 H4 C1 C4 D3 C8 D8 H13
output:
Alice
result:
ok single line: 'Alice'
Test #3:
score: 0
Accepted
time: 206ms
memory: 27044kb
input:
C5 H9 S12 D6 S10 C2 D11 S11 H5 C6 C12 C9 S4 D3 S7 S9 H1 H2 C3 S6 D1 S5 D2 H3 D12 C1
output:
Bob
result:
ok single line: 'Bob'
Test #4:
score: 0
Accepted
time: 209ms
memory: 26452kb
input:
D1 H9 H5 S4 D13 S8 H12 S5 D9 D5 C10 C8 D4 S12 S13 C4 H10 D6 H11 H8 C12 H2 S2 S6 H1 H13
output:
Bob
result:
ok single line: 'Bob'
Test #5:
score: 0
Accepted
time: 275ms
memory: 26956kb
input:
H2 D2 C9 H4 H10 C1 D1 D8 H7 C10 C3 S3 D10 S13 D6 C13 D5 C6 S8 H11 H3 H9 S4 S6 D13 H6
output:
Alice
result:
ok single line: 'Alice'
Test #6:
score: 0
Accepted
time: 109ms
memory: 28004kb
input:
C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13
output:
Draw
result:
ok single line: 'Draw'
Test #7:
score: 0
Accepted
time: 117ms
memory: 27780kb
input:
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 H1 H2 H3 H4 H5 H6 H7 D1 D2 D3 D4 D5 D6
output:
Draw
result:
ok single line: 'Draw'
Test #8:
score: 0
Accepted
time: 118ms
memory: 27684kb
input:
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 D12
output:
Draw
result:
ok single line: 'Draw'
Test #9:
score: 0
Accepted
time: 409ms
memory: 27460kb
input:
S2 S4 S6 S8 S10 S12 H1 H3 H5 H7 H9 H11 H13 C1 C3 C5 C7 C9 C11 C13 D2 D4 D6 D8 D10 D12
output:
Alice
result:
ok single line: 'Alice'