QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#588482 | #2405. Tic-Tac State | Tenshi | AC ✓ | 8ms | 3640kb | C++20 | 1.4kb | 2024-09-25 11:58:15 | 2024-09-25 11:58:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << ": " << (x) << endl
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dwn(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
using pii = pair<int, int>;
using ll = long long;
inline void read(int &x){
int s=0; x=1;
char ch=getchar();
while(ch<'0' || ch>'9') {if(ch=='-')x=-1;ch=getchar();}
while(ch>='0' && ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
x*=s;
}
vector<int> w;
int n;
bool ok(vector<int> g){
while(g.size()!=3) g.pb(0);
if(g[0]==7 || g[1]==7 || g[2]==7) return true;
if(g[0]>>2 && g[1]>>2 && g[2]>>2) return true;
if(g[0]>>1&1 && g[1]>>1&1 && g[2]>>1&1) return true;
if(g[0]&1 && g[1]&1 && g[2]&1) return true;
if(g[0]&1 && g[1]>>1&1 && g[2]>>2&1) return true;
if(g[0]>>2&1 && g[1]>>1&1 && g[2]&1) return true;
return false;
}
void solve(){
string s; cin>>s;
while(s.size()<7) s="0"+s;
n=s.size();
w.clear();
rep(i, 0, n-1) w.pb(s[i]-'0');
vector<int> a, b;
rep(i, n-3, n-1) a.pb(w[i]);
rep(i, n-3-3, n-3-1) b.pb(w[i]);
rep(i, 0, 3-1) a[i]^=b[i];
int st=0;
if(ok(a)) st=1;
else if(ok(b)) st=2;
if(!st){
if(s.substr(s.size()-3)=="777") puts("Cat's");
else puts("In progress");
}
else puts(st==1? "O wins": "X wins");
}
signed main(){
int cs; cin>>cs;
while(cs--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
4 01116777 07037 01416777 050055
output:
O wins X wins Cat's In progress
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
1 00
output:
In progress
result:
ok single line: 'In progress'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
5477 01000004 01000001 01000002 01000010 020021 01020025 020022 01020026 020024 01000020 01020023 01020034 020030 01020031 01020032 040041 01040045 040042 01040046 040044 01000040 01040043 01040054 040050 01040051 01040052 01020064 01040064 040060 020060 060063 01060067 060065 01020061 01040061 0600...
output:
In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress ...
result:
ok 5477 lines
Test #4:
score: 0
Accepted
time: 8ms
memory: 3612kb
input:
5477 020020 01020024 01020021 01020022 01020030 040040 01040044 01040041 01040042 01040050 060061 01060065 060062 01060066 060064 01020060 01040060 01060063 01060074 060070 01060071 01060072 0100100 01100104 01100101 01100102 01100110 0120121 01120125 0120122 01120126 0120124 01020120 01100120 01120...
output:
In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress In progress ...
result:
ok 5477 lines