Codeforces Round #658 (Div. 2) 1382C1. Prefix Flip (Easy Version) Solution




Problem Link :  https://codeforces.com/contest/1382/problem/C1 

 Solution in C++:

///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long  t,n,i;
    cin>>t;
    while(t--)
    {
        cin>>n;
        string a,b;
        vector<int>v;
        cin>>a>>b;
        if(a[0]!=b[0])
            v.push_back(1);
        for(i=1; i<n; i++)
        {
            if(a[i]!=b[i])
            {
                v.push_back(i+1);
                v.push_back(1);
                v.push_back(i+1);
            }
        }
        cout<<v.size()<<" ";
        for(i=0;i<v.size();i++)
        {
            cout<<v[i]<<" ";
        }
        cout<<endl;
    }
}
 



 


No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.