QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468382#8523. Puzzle IIucup-team3519#WA 0ms3824kbC++201.4kb2024-07-08 20:33:382024-07-08 20:33:38

Judging History

This is the latest submission verdict.

  • [2024-07-08 20:33:38]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3824kb
  • [2024-07-08 20:33:38]
  • Submitted

answer

#pragma GCC optimize(3,"Ofast","inline")
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
#define ll long long
const int N=300005;
const ll mod=998244353;
ll qpow(ll a,ll b){
	ll ans=1;
	if(b==0)
	return 1;
	if(b%2)
	ans=a;
	ll t=qpow(a,b/2);
	return t*t%mod*ans%mod;
}
ll inv(ll a){
	return qpow(a,mod-2);
}
string a,b;
int n,k;
int swtag=0;
struct pt{
	int x1;
	int x2;
	int x3;
	int x4;
};
vector<pt>ans;
void fr(int x1,int x2,int y1,int y2){
	x1=((x1)%n+n)%n+1;
	x2=((x2)%n+n)%n+1;
	y1=((y1)%n+n)%n+1;
	y2=((y2)%n+n)%n+1;
	ans.push_back({x1,x2,y1,y2});
}

void op(){
	cout<<ans.size()<<'\n';
	for(int i=0;i<ans.size();i++){
		if(swtag==0)
		cout<<ans[i].x1<<' '<<ans[i].x3<<'\n';
		else
		cout<<ans[i].x3<<' '<<ans[i].x1<<'\n';
	}
}
void solve(){
	cin>>n>>k;
	cin>>a>>b;
	int cnt=0;
	for(int i=0;i<n;i++){
		if(a[i]=='B')cnt++;
		else cnt--;
	}
	if(cnt<0){
		swap(a,b);
		swtag=1;
	}
	int cb=0;
	vector<int>ext(n*2+5);
	vector<int>nd,na;
	int cur=0;
	for(int i=0;i<n;i++){
		if(b[i]=='B'){
			
			nd.push_back(i+cur);
			cur--;
			ext[i+k]++;
			cur+=ext[i];
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]=='C'){
			na.push_back(i);
		}
	}
	for(int i=0;i<na.size();i++){
		int x=na[i],y=nd[i];
		fr(x-k+1,x,y+1,y+k);
		fr(x-k+1,x,y,y+k-1);
	}
	op();
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	solve();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

6 3
BCCBCC
BBCBBC

output:

4
2 1
1 1
4 4
3 4

result:

ok moves = 4

Test #2:

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

input:

2 1
BC
BC

output:

2
2 2
2 1

result:

ok moves = 2

Test #3:

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

input:

2 1
BB
CC

output:

0

result:

ok moves = 0

Test #4:

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

input:

2 1
CC
BB

output:

0

result:

ok moves = 0

Test #5:

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

input:

3 1
CCC
BBB

output:

0

result:

ok moves = 0

Test #6:

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

input:

3 1
CBC
BCB

output:

2
3 2
2 2

result:

ok moves = 2

Test #7:

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

input:

3 2
BBB
CCC

output:

0

result:

ok moves = 0

Test #8:

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

input:

3 2
BCB
BCC

output:

2
1 2
1 1

result:

ok moves = 2

Test #9:

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

input:

4 2
CCCB
BBCB

output:

2
1 2
4 2

result:

ok moves = 2

Test #10:

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

input:

9 6
CCCBCCCBB
BBBCBBBCC

output:

6
5 8
4 8
8 3
7 3
8 4
7 4

result:

wrong answer The final sequences are not correct!