QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#631227 | #6820. Youth Finale | sazhi | WA | 1ms | 3556kb | C++20 | 2.1kb | 2024-10-11 23:06:01 | 2024-10-11 23:06:02 |
Judging History
answer
// author: jieda
// file: cpp
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
# define fi first
# define se second
# define all(x) x.begin(),x.end()
# define stst stringstream
# define pb push_back
# define pf push_front
# define pp push
# define lowbit(x) (x)&(-x)
# define fa(i,op,n) for (int i = op; i <= n; i++)
# define fb(j,op,n) for (ll j = op; j >= n; j--)
# define fg(i,op,n) for (ll i = op; i != n; i = ne[i])
int dx[4] = {-1,0,1,0},dy[4] = {0,1,0,-1};
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int N = 599999,INF = 0x3f3f3f3f,mod = 998244353;
const ll MOD = 212370440130137957ll;//hash(hight)
const int base = 131;
const double eps = 1e-10;
const int seed=10086,mo=1e6+7; //hash(lower)
int prime = 233317;
struct arraytree{
int n;
vector<ll> tr;
void init(){
tr.resize(n<<1);
}
void add(ll x,ll k) {
while(x<=n){
tr[x] += k;
x += lowbit(x);
}
}//单点增加
ll query (ll x){
ll ans = 0;
while(x){
ans += tr[x];
x -= lowbit(x);
}
return ans;
}
};
void solve(){
int n,m;cin>>n>>m;
arraytree tr;tr.n = n+1;tr.init();
ll ans = 0;
vector<int> a(n+1);
for(int i = 1;i<=n;i++){
int x;cin>>x;
a[i] = x;
int t = tr.query(x);
ans += (x-1-t);
tr.add(x,1);
}
cout<<m<<'\n';
string s;cin>>s;s = " "+s;
int now = 1;
bool tag = 0;
for(int i = 1;i<=m;i++){
char c = s[i];
if(c == 'R'){
tag = !tag;
if(tag){
now = now-1;
}else{
now = now+1;
}
}
now = (now+n)%n == 0?n:(now+n)%n;
//cout<<c<<' '<<a[now]<<'\n';
if(c == 'S'){
ans = (ans-(a[now]-1)+(n-a[now])+10)%10;
}else{
ans = (n*1ll*(n-1)/2-ans+10)%10;
}
if(c == 'S'){
if(tag){
now = now-1;
}else{
now = now+1;
}
}
now = (now+n)%n == 0?n:(now+n)%n;
cout<<ans;;
}
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t = 1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
/**/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3556kb
input:
5 10 5 4 3 2 1 SSSSRSSSSR
output:
10 6446466400
result:
ok 2 tokens
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3544kb
input:
1 1 1 R
output:
1 0
result:
wrong answer 1st words differ - expected: '0', found: '1'