QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#185383 | #6128. Flippy Sequence | chitoge | WA | 0ms | 3524kb | C++20 | 1.9kb | 2023-09-21 23:25:15 | 2023-09-21 23:25:16 |
Judging History
answer
#pragma GCC optimize("Ofast")
//booster_^^
#include<bits/stdc++.h>
#define FC(a,b,c) for(int i=a;i<b;i++)cin>>c[i]
#define Fn(n) for(int i=0;i<n;i++)
#define fin(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define F(a,b) for(int i=a;i<b;i++)
#define all(a) a.begin(),a.end()
#define umap_boost(x) x.reserve(1024);x.max_load_factor(0.25);
#define PII pair<int,int>
#define ll long long
#define endl '\n'
using namespace std;
inline void cin_unlocked()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
}
template <typename T>
inline void stable_unique(vector<T>& v ){
set<T> m(v.begin(),v.end());
v.assign(m.begin(),m.end());
}
class dsu{
public:
int n;
vector<int> c;
int q(int x){
if(c[x]!=x){
c[x]=q(c[x]);
}
return c[x];
}
void u(int a,int b){
int fa=q(a);
int fb=q(b);
if(fa!=fb)
c[fa]=fb;
}
dsu(int &_n){
this->n=_n+5;
this->c.resize(n);
for(int i=0;i<n;i++)c[i]=i;
}
};
int pow_mod(int a, int b,int mod) {//a^b
int ans = 1;
while(b > 0) {
if(b & 1) ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
}
inline void solve(){
int n;
cin>>n;
string s,t;
cin>>s>>t;
string d=s;
vector<int> dif[3];
if(n==1){
cout<<(s[0]==t[0])<<endl;
return;
}
int l=1;
for(int i=0;i<n;i++){
d[i]=s[i]==t[i];
if(!i)continue;
if(d[i]!=d[i-1]){
dif[!d[i]].emplace_back(l);
l=1;
}else{
l++;
}
}
if(l){
dif[d[n-1]].emplace_back(l);
}
if(dif[1].size()==0){
cout<<n+(n*(n-1))/2<<endl;
}else if(dif[1].size() == 1){
cout<<2*(n-1)<<endl;
}else if (dif[1].size() == 2){
cout<<6<<endl;
}else{
cout<<0<<endl;
}
}
int main(){
cin_unlocked();
int t;cin>>t;for(;t--;)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3524kb
input:
3 1 1 0 2 00 11 5 01010 00111
output:
0 3 6
result:
wrong answer 2nd numbers differ - expected: '2', found: '3'