QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#434611#8789. Spin & Rotate!ucup-team1004#WA 0ms3820kbC++141.4kb2024-06-08 16:45:562024-06-08 16:45:58

Judging History

This is the latest submission verdict.

  • [2024-06-08 16:45:58]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3820kb
  • [2024-06-08 16:45:56]
  • 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;
	reverse(all(a));
	string res;
	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(;ans.size()>2;){
		if(ans.back()=='R'){
			if(ans.size()>2&&ans.substr(ans.size()-3,3)=="RSR"){
				for(int t=3;t--;)ans.pop_back();
			}else break;
		}else{
			// int cur=ans.size()-2;
			ans.pop_back();
			// for(;cur>=0&&ans[cur]=='R';cur--);
			// if(cur<0)break;
			assert(!ans.empty()&&ans.back()=='R');
			for(;!ans.empty()&&ans.back()=='R';ans.pop_back());
			if(ans.empty())ans+='S';
			else ans.pop_back();
		}
	}
	if(ans=="")ans="S";
	for(int i=0;i+4<ans.size();i++){
		assert(ans.substr(i,5)!="RSRSR");
	}
	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: 0ms
memory: 3820kb

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: 3556kb

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: 3616kb

input:

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

output:

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

result:

wrong answer 11th words differ - expected: 'S', found: 'RS'