QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#773010 | #8789. Spin & Rotate! | Crysfly | WA | 1ms | 3828kb | C++14 | 2.0kb | 2024-11-22 23:33:59 | 2024-11-22 23:34:00 |
Judging History
answer
// what is matter? never mind.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define ll __int128
//#define ull unsigned long long
#define int long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
return f?-x:x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<ll,ll>pii;
typedef vector<int>vi;
#define maxn 5005
#define inf 0x3f3f3f3f
string ns,s;
bool chk(){
if(s.size()>=6){
string t;
For(i,s.size()-6,s.size()-1) t+=s[i];
if(t=="RSRSRS"){
For(_,1,6) s.pop_back();
return 1;
}
}
if(s.size()>=2){
if(s.back()=='S' && s[s.size()-2]=='S'){
For(_,1,2)s.pop_back();
return 1;
}
}
return 0;
}
void work()
{
cin>>ns; s="";
reverse(ns.begin(),ns.end());
for(auto ch:ns){
if(ch=='S')s+='S';
else {
string t="SRSRS";
for(auto cc:t) {
s+=cc;
while(chk());
}
}
while(chk());
}
while(s.size()>=3 && s.back()=='R' && s[s.size()-2]=='S' && s[s.size()-3]=='R') {
For(_,1,3) s.pop_back();
while(chk());
}
while(s.size()>=3 && s.back()=='S' && s[s.size()-2]=='R' && s[s.size()-3]=='S') {
For(_,1,3) s.pop_back();
while(chk());
}
if(s.size()==0)s+='S';
cout<<s<<"\n";
}
/*
x=0
S : x -> -1/x
R : x -> x+1
SR 0 -inf -inf
RS -> S?
S R S R S R
0 -inf -inf 0 1 -1 0
? S R S
0 -inf -inf 0
*/
signed main()
{
// freopen("my.out","w",stdout);
int T=read();
while(T--)work();
return 0;
}
/*
4
0000
0111
1100
1011
0110
0001
1010
1101
0011
0100
1111
1000
0101
0010
1001
1110
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
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: 1ms
memory: 3828kb
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: 3608kb
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'