Untitled
unknown
plain_text
5 months ago
2.1 kB
8
Indexable
#include <bits/stdc++.h> using namespace std; #define int long long void __print(int x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned int x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } #ifndef ONLINE_JUDGE #define debug(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #define debug(x...) #endif void solve() { int n; cin >> n ; string a; string b; cin >> a >> b; string temp = b; reverse(temp.begin(), temp.end()); string c = temp; //normal int count1= 0; for(int i=0;i<n;i++){ if(a[i]!=b[i]){ count1++; } } if(count1 == 0 ){ cout<<0<<endl; return; } if(count1 == 1){ cout<<1<<endl; return; } int ans1= count1*2-1; debug(count1,ans1); //reverse int count2 = 0; for(int i=0;i<n;i++){ if(a[i]!=c[i]){ count2++; } } //oyoyoy //yoyoyo //yoyoyo int ans2 = count2*2; debug(count2,ans2); if(count2 ==0){ ans2 = 2; cout << ans2 << endl; return; } cout<<min(ans1,ans2)<<endl; // abcdefgh // hbfduegh } signed main() { int t = 1; cin >> t; while (t--) { debug(t); solve(); } return 0; }
Editor is loading...
Leave a Comment