QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234999 | #7218. The Ultimate Duel | abcde777 | WA | 1ms | 5788kb | C++14 | 940b | 2023-11-02 10:28:36 | 2023-11-02 10:28:36 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N = 100010;
char s[N],t[N];
int sr[N],sp[N],ss[N],ts[N],tr[N],tp[N];
int slen,tlen;
int gcd(int x,int y) {
if(!y) return x;
return gcd(y,x%y);
}
//rsp
int main()
{
//cout<<gcd(60,12)<<endl;
cin>>(s+1)>>(t+1);
slen=strlen(s+1);
tlen=strlen(t+1);
int g=gcd(slen,tlen);
for(int i=1;i<=slen;++i) {
if(s[i]=='R') sr[i%g]++;
else if(s[i]=='P') sp[i%g]++;
else ss[i%g]++;
}
for(int i=1;i<=slen;++i) {
if(t[i]=='R') tr[i%g]++;
else if(t[i]=='P') tp[i%g]++;
else ts[i%g]++;
}
long long swin=0;
for(int i=0;i<g;++i) {
// cout<<i<<' '<<sr[i]<<' '<<ss[i]<<' '<<sp[i]<<endl;
swin+=sr[i]*ts[i]+ss[i]*tp[i]+sp[i]*tr[i];
swin-=tr[i]*ss[i]+ts[i]*sp[i]+tp[i]*sr[i];
}
if(swin==0) cout<<"Rowdark"<<endl;
else if(swin>0) cout<<"TankEngineer"<<endl;
else cout<<"AngryBacon"<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5788kb
input:
R S
output:
TankEngineer
result:
ok "TankEngineer"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5700kb
input:
RPSSPR RSR
output:
AngryBacon
result:
ok "AngryBacon"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5588kb
input:
PPPSSSRRR R
output:
Rowdark
result:
ok "Rowdark"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
RRRSRPSRPP SSPRRSRSRR
output:
TankEngineer
result:
ok "TankEngineer"
Test #5:
score: 0
Accepted
time: 1ms
memory: 5740kb
input:
PRPRRRPPSSPSSPPSPPRS PSPPRRRPPP
output:
TankEngineer
result:
ok "TankEngineer"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
SPSSSSSPRPSRPRPPSRSRPRPSSPSSRS SRSRRRSSPRPSSRRRPSSR
output:
AngryBacon
result:
ok "AngryBacon"
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 5592kb
input:
SPSPPSSSRSSRPPPRRPSRSRRSPSRRRSRPSSPRRPPS PRPPPSPPPRRPPSPRPPSRSRSRPPSPRSSRPSPRRRSSPRRRSRRSSSPPPRRPPPRR
output:
TankEngineer
result:
wrong answer 1st words differ - expected: 'Rowdark', found: 'TankEngineer'