QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398890#8046. Rock-Paper-Scissors PyramidwdwWA 10ms12096kbC++202.2kb2024-04-25 19:30:392024-04-25 19:30:46

Judging History

你现在查看的是最新测评结果

  • [2024-04-25 19:30:46]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:12096kb
  • [2024-04-25 19:30:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
//#define int long long
#define endl '\n'
const int N = 1e6+5;
const int mod=3;
long long jc[N];
void caljc() {
    jc[0] = jc[1] = 1;
    for (int i = 2; i < N - 3; i++) {
        jc[i] = jc[i - 1] *i% mod;
    }
}
long long ksm(long long a, long long b, long long p) {
    long long ans = 1;
    while (b) {
        if (b & 1)ans = ans * a % p;
        a = a * a % p;
        b /= 2;
    }
    return ans;
}
long long c(long long a, long long b,long long p) {
    if (b> a)return 0;
    return (jc[a] % p * ksm(jc[b], p-2, p) % p) % p * ksm(jc[a - b], p-2, p) % p;
}
long long  Lucas(long long n, long long  m,long long p)
{
    if (m == 0) return 1;
    return (Lucas(n / p, m / p,p) * c(n % p, m % p,p)) % p;//进入到C中的参数均小于P,所以初始阶乘时只需预处理到p即可
    //这也是卢卡斯定理只适用与p<1e5的原因
}
void solve(){
    string s;
    cin>>s;
    int n;
    n=s.length();
    int ans=0;
    int l1=-1,l2=-1,l3=-1;
    for(int i=0;i<n;i++) {
        if(s[i]=='S'){
            l1=i;
        }else if(s[i]=='P'){
            l2=i;
        }else{
            l3=i;
        }
    }
    if(l1==-1){
        if(l2==-1){
            cout<<'R'<<endl;
            return;
        }else{
            cout<<"P"<<endl;
            return;
        }
    }else if(l2==-1){
        if(l3==-1){
            cout<<'S'<<endl;
            return;
        }else{
            cout<<"R"<<endl;
            return;
        }
    }else if(l3==-1){
        if(l1==-1){
            cout<<'P'<<endl;
            return;
        }else{
            cout<<"S"<<endl;
            return;
        }
    }

    if(l1<l2&&l2<l3){
        cout<<'S'<<endl;
    }else if(l1<l3&&l3<l2){
        cout<<'P'<<endl;
    }else if(l2<l1&&l1<l3){
        cout<<'R'<<endl;
    }else if(l2<l3&&l2<l1){
        cout<<'P'<<endl;
    }else if(l3<l1&&l1<l2){
        cout<<'R'<<endl;
    }else if(l3<l2&&l2<l1){
        cout<<'S'<<endl;
    }


}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int T=1;
    caljc();
    cin>>T;
    while(T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 11532kb

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 10ms
memory: 12096kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

P

result:

wrong answer 1st lines differ - expected: 'R', found: 'P'