QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#448018#8523. Puzzle IImarherWA 1ms3592kbC++141.1kb2024-06-19 08:41:372024-06-19 08:41:38

Judging History

This is the latest submission verdict.

  • [2024-06-19 08:41:38]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3592kb
  • [2024-06-19 08:41:37]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+50;

int n,k,a[N],b[N],cc,tot,d[N],p[N];
pair<int,int>st[N];
char s[N];
vector<int>f,g;

void rd(int*a)
{
    cin>>(s+1);
    for(int i=1;i<=n;i++)a[i]=(s[i]=='B');
}

void out(int x,int y)
{
    x--;x=(x%n+n)%n+1;
    y--;y=(y%n+n)%n+1;
    st[++tot]=make_pair(x,y);
}

void mk(int x,int y)
{
    out(x,y-k);
    out(x,y-k+1);
}

main()
{
    // freopen("in.txt","r",stdin);
    cin>>n>>k;rd(a);rd(b);
    for(int i=1;i<=n;i++)cc+=a[i];
    if(cc>n-cc)for(int i=1;i<=n;i++)a[i]^=1,b[i]^=1;
    for(int i=1;i<=n;i++)if(a[i])f.push_back(i);
    for(int i=n;i>=1;i--)if(!b[i])g.push_back(i);
    for(int i=0,del=0,p1=0,p2=0,ad=0;i<f.size();i++)
    {
        p1=max(p1,i);p2=max(p2,i);
        int A=f[i]-del;
        while(p1+1<f.size()&&f[p1+1]<A+k)p1++,f[p1]+=del;
        int B=g[i]+ad;
        while(p2+1<g.size()&&g[p2+1]>=B-k)p2++,g[p2]-=ad;
        ad++;del++;mk(A,B);
    }
    cout<<tot<<'\n';
    for(int i=1;i<=tot;i++)cout<<st[i].first<<' '<<st[i].second<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3592kb

input:

6 3
BCCBCC
BBCBBC

output:

4
1 3
1 4
3 1
3 2

result:

wrong answer The final sequences are not correct!