QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#508903#8046. Rock-Paper-Scissors Pyramid333zhanTL 47ms26192kbC++201.8kb2024-08-07 21:42:212024-08-07 21:42:22

Judging History

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

  • [2024-08-07 21:42:22]
  • 评测
  • 测评结果:TL
  • 用时:47ms
  • 内存:26192kb
  • [2024-08-07 21:42:21]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long

using namespace std;

inline int read () {
    int w = 1, s = 0; char ch = getchar ();
    for (; ! isdigit (ch); ch = getchar ()) if (ch == '-') w = -1;
    for (; isdigit (ch); ch = getchar ()) s = (s << 1) + (s << 3) + (ch ^ 48);
    return s * w;
}

bool fight (int x, int y) {
    if (x == 1 && y == 3) {
        return true;
    }
    if (x == 2 && y == 1) {
        return true;
    }
    if (x == 3 && y == 2) {
        return true;
    } 
    return false;
}

void solve () {
    string s;
    cin >> s;

    const int n = s.size ();

    int change[200];
    change['S'] = 1;
    change['R'] = 2;
    change['P'] = 3;

    vector <int> a;
    for (auto c : s) {
        a.push_back (change[c]);
    }
    
    for (int i = 1; i < n && a.size () > 1; i ++) {
        vector <int> b;
        for (int j = 0; j < a.size () - 1; j ++) {
            if (a[j] == a[j + 1]) {
                if (j == a.size () - 2) {
                    b.push_back (a[j]);
                }
                continue;
            } else if (fight (a[j], a[j + 1])) {
                b.push_back (a[j]);
            } else {
                b.push_back (a[j + 1]);
            }
        }
        a.swap (b);
    }

    if (a[0] == 1) {
        cout << 'S' << '\n';
    } else if (a[0] == 2) {
        cout << 'R' << '\n';
    } else {
        cout << 'P' << '\n';
    }   
} 

signed main () {
	// freopen ("data1.in", "r", stdin);
	// freopen ("data1.out", "w", stdout);
	
    ios::sync_with_stdio (false);
    cin.tie (nullptr);
    
	int T = 1; 
	cin >> T;
	// T = read ();

	while (T --) {
		solve ();
	}
	
	return 0;
}
/*
1    2    3
剪刀 石头  布

2 3 1 2 3 1 1 3
1 2 3 1 2 3 1 3 2

2 2
1 2 1
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
SPR
SPSRRP

output:

S
P

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 35ms
memory: 24192kb

input:

1
RPPSRPPRSRSRRRPPSPRPRSRRSRRPPPRSPSSRRRSPPPRRRPRRRSSRPSSRPRRPSRRRPRSRPSRPSRRSPPRPRRRSPRSSSRPRRRPPSRRRRPPSRSRRRPRPRPRPPRRSRRPSRPPSRRRSRRSRRSPSRPRPSPSSRRSPSPSRPRRRPPRSRSPSPPRRPRSRPPSSSRPSPRRPSSSPRRSRRSRRSRSPSSSSRSSPPRRRRPRRRSPSRSPRSSPRSPSPRPRRRPPRPPRPPPSRRRRSSPRRSRRRPRRRSSRRPSRPPRSPPSPPPSPSPSPPSSPRRR...

output:

R

result:

ok single line: 'R'

Test #3:

score: 0
Accepted
time: 18ms
memory: 20236kb

input:

1
PPPPPSPPPRPPPPRRPSRPPRSSRPPPPPPRPPPPRPPSPPPPPPPRPPRRPPRPPSPPPPRRPSPRSPPPPPPRRRPRPRPPPPPPRPPPPPPPSPPPPPPPPRPPPPSPPRPPPPPSPPRPPPSRPPPPRPPRPPRPPPSPPPPPPPRPPRRPPSPRPRPPPPPRPPPPPPPRPRRRSPPPPPSPSPSRPRPSPSPPPPPRSPPPPPRPPPRPPPPPPSRRRPPPPRPSPPSRPPRPPRPPPRRSPPPRRRPPRPPPPPRPPPSPRPPRPPPRPSPPPRPPPPPRRPPSPRPRPR...

output:

P

result:

ok single line: 'P'

Test #4:

score: 0
Accepted
time: 26ms
memory: 3676kb

input:

500
SSSPSSSPRPSPPPPRRPSPSRSPSPPSRPPRRRSRRSPRPRRRRPSSPPRRSPPPSRRSPSPRRSSPPSRPRPPSSPSSRSSSRRSSPSSRSRRPSPSRSSRSRRPRRRPSSPPPSRPSSPPSSPSSPPRRPPRSPSRSRPRRSSRSSRPRRPRSRRPPRRPPRRRRRRRSR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RSRSRSPSSPPPPPRRPSSRSRRPRSSRPSPPRPPPSPSSSSRPSPRSSPSRRRPPSSSPPRSSSRPRRSPPPRRPSPPRPPSPSRRRPPPPRRPPRSSRSSPPRS...

output:

P

result:

ok single line: 'P'

Test #15:

score: 0
Accepted
time: 38ms
memory: 9640kb

input:

4
PRSRPRSPSRPRPRSRPSPRSPSPSRSPSPSRSRSRSPSRSPSRSPRSRPRPRSRSRPSPSRPRSRPRSRPRPRPSRSRSRSPSRPSRSPRSPSPRSPRPSRPRPRPSRPSPSRSPRPRPSPRPRSPRPSRPRPRSRSPRPRSPSPRSPRSRSPRPSRSPSPRSPSPRPRPRSPRSPSPSPRPSRPRSPSRSPRSPSPRPRPRPSRPRPSRSRPRSRPRPRPSRPSPRPRSRSRSRPSRPRPRPRPSRSPSPSRSRPSPSPSPRPRPRSRPRSRPSRPSPRPSPSRPRSRSRSRPSPR...

output:

S
R
R
S

result:

ok 4 lines

Test #16:

score: 0
Accepted
time: 29ms
memory: 13092kb

input:

3
SRPRPSPSPRSRPRSRSPRSRPRSRPRPRPSPRSRSRPSPRSPSPRSRSPRPSPSPRPSRSPRPRPSRPRSRPSPSRSPSRPSRPRSRPSPSRSPRSRSPRSPRPSPSPSPRPRSPSRPSRSRPSRSRSPSPRSRPSRPRSRSPRSPSRSPSPRSRPRSPSPRPRPRSRPRPSPRSRPSPRPRSRPRSRSRPSPSRSPRPSRPRPSPSRPRPRSPRSPSPSRPRPSRPRPSPSPRPSPRPRSRPRSPSRSPRPRSRPSPSRSRSRPRSPSRSPSPSRSPRPSRPSPSRPRPRSPRPSR...

output:

S
P
P

result:

ok 3 lines

Test #17:

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

input:

1
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

R

result:

ok single line: 'R'

Test #18:

score: -100
Time Limit Exceeded

input:

1
RSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPRSPR...

output:


result: