QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#631236#6820. Youth FinalesazhiWA 1ms3812kbC++202.2kb2024-10-11 23:13:412024-10-11 23:13:41

Judging History

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

  • [2024-10-11 23:13:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3812kb
  • [2024-10-11 23:13:41]
  • 提交

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(){
	ll 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;
		ll t = tr.query(x);
		ans += (x-1-t);
		tr.add(x,1);
	}
	cout<<ans<<'\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(a[now] == 691){
		    cout<<c<<'\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: 0ms
memory: 3812kb

input:

5 10
5 4 3 2 1
SSSSRSSSSR

output:

10
6446466400

result:

ok 2 tokens

Test #2:

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

input:

1 1
1
R

output:

0
0

result:

ok 2 tokens

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3636kb

input:

1000 2000
313 691 343 806 897 516 38 769 391 353 43 55 246 7 65 790 185 362 60 203 642 66 731 64 760 780 266 920 805 48 724 788 730 560 766 491 748 986 439 904 619 749 652 571 617 785 202 588 234 5 717 113 84 823 399 282 269 894 703 745 886 364 258 177 622 621 573 322 487 422 413 58 39 436 543 756 9...

output:

251209
4S
-78-3-6-78-90501078-1078309-21-8-72-7-69-8-3-2-1-27-8-94-30-70-1-4-34-123058-7636-1-6-5-6729-4-507416143-2-36-1692-123216-3-498903-6-18303-25410-70-1878-1-4-32-561-4-1430-905438-3-836-3-8-5-816-14-7-29694307-6-769-410-36-1-61-6-36-38-3-8-9-29-8-5-8-3-21-4-18509-818-1-49-87-250-90789030-90-...

result:

wrong answer 2nd words differ - expected: '438743810501078907830981232349...6787892107230123090509276327619', found: '4S'