Codeforces Round #658 (Div. 1) 1381A1 - Prefix Flip (Easy Version) Solution
Problem Link : https://codeforces.com/contest/1381/problem/A1
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