//struct Edge {int u, v, weight;bool operator<(Edge const& other) {return weight < other.weight;}};
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define sp ' '
#define pb push_back
#define ar for(int i=1;i<=n;i++)
using namespace std;
ll t=1;
const ll N=3e5+100;
ll n,m,q,k;
bool vis[N];
ll mx=0;
ll ans=0;
ll last;
char a[N];
pair<int,int>p[N];
void solve()
{
map<char,int>mp;
cin>>n;
for(int i=1;i<=2*n;i++)
{
cin>>a[i];
}
for(int i=n+1;i<=2*n;i++){mp[a[i]]=i-n;}
ll cur=0;
for(int i=1;i<=n;i++)
{
ans+=mp[a[i]]-i-cur;cur++;
}
cout<<abs(ans)<<endl;return;
}
int main()
{
//freopen("shell.in", "r", stdin);
// freopen("shell.out", "w", stdout);
ios::sync_with_stdio(NULL);
cin.tie(NULL);cout.tie(NULL);
// cin>>t;
while(t--){solve();}
return 0;
}
//09:00 :: 9:45
//10:30 ::
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |