QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#601390 | #6128. Flippy Sequence | 122 | WA | 0ms | 3588kb | C++14 | 922b | 2024-09-29 22:50:04 | 2024-09-29 22:50:05 |
Judging History
answer
#include <bits/stdc++.h>
#define endl "\n"
#define int long long
#define PII std::pair<int, int>
#define PSS std::pair<string, string>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define inf 0x3f3f3f3f
//#define lc p<<1
//#define rc p<<1|1
#define PIS pair<int,string>
using namespace std;
const int N=1e5+10;
void solve() {
int n;
cin>>n;
string s1,s2;
cin>>s1>>s2;
s1="!"+s1;
s2="!"+s2;
int cnt=0;
int a=0;
for(int i=1;i<=n;i++)
{
if(s1[i]==s2[i]) continue;
cnt++;int now=i;
while(s1[i]!=s2[i]&&i<=n) i++;
a=i-now;
// cout<<a<<endl;
}
// cout<<a<<endl;
if(cnt>2)
{
cout<<0<<endl;
}
else if(cnt==1)
{
int len=n-a;
int res=2*len;
res+=2*(a-1);
}
else if(cnt==2)
{
cout<<6<<endl;
}
else if(cnt==0)
{
cout<<n*(n-1)/2<<endl;
}
}
signed main() {
IOS; cout.tie(0);
int t=1;
cin>>t;
while(t--) solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3588kb
input:
3 1 1 0 2 00 11 5 01010 00111
output:
6
result:
wrong answer 1st numbers differ - expected: '0', found: '6'