QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#434417#8789. Spin & Rotate!ucup-team1004#WA 1ms3788kbC++141.1kb2024-06-08 16:07:102024-06-08 16:07:14

Judging History

This is the latest submission verdict.

  • [2024-06-08 16:07:14]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3788kb
  • [2024-06-08 16:07:10]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned ll;
int T;
string a;
void get(){
	cin>>a;
	string res;
	reverse(all(a));
	for(char c:a){
		if(c=='R')res+="SRSRS";
		else res+="S";
	}
	string ans;
	for(char c:res){
		if(c=='S'){
			if(ans.size()>0&&ans.back()=='S')ans.pop_back();
			else if(ans.size()>4&&ans.substr(ans.size()-5,5)=="RSRSR"){
				for(int t=5;t--;)ans.pop_back();
			}else ans+=c;
		}else ans+=c;
	}
	// debug(ans);
	for(;;){
		if(ans.size()>2&&ans.substr(ans.size()-3,3)=="RSR"){
			for(int t=3;t--;)ans.pop_back();
		}else if(ans.size()>2&&ans.substr(ans.size()-3,3)=="SRS"){
			for(int t=3;t--;)ans.pop_back();
		}else break;
	}
	if(ans=="")ans="S";
	cout<<ans<<'\n';
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	for(cin>>T;T--;)get();
	return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

14
R
S
RR
SR
RS
SS
RRR
SRR
RSR
SSR
RRS
SRS
RSS
SSS

output:

SR
S
SRSRR
S
R
S
SRSRRSRR
S
S
SR
RSRR
S
SR
S

result:

ok 14 tokens

Test #2:

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

input:

5
SRRSRRSRR
SRRRSRRR
RRRSRRRSRRR
SRRSRRSRRSRRSRRSRRSRRSRRSRRSR
SRRRSRRRSRRRSRRRSRRRSRRRSRRRS

output:

SRSRRR
SRSRRSRR
SRSRRSRRRSRRRSRR
SRRRRRRRRR
RSRRSRRRSRRRSRRRSRRRSRRRSRR

result:

ok 5 tokens

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3656kb

input:

16
RRRR
SRRR
RSRR
SSRR
RRSR
SRSR
RSSR
SSSR
RRRS
SRRS
RSRS
SSRS
RRSS
SRSS
RSSS
SSSS

output:

SRSRRSRRSRR
S
SRSRRS
SRSRR
SRR
SR
SRSRR
S
RSRRSRR
S
RS
R
SRSRR
S
R
S

result:

wrong answer 3rd words differ - expected: 'SR', found: 'SRSRRS'