Submission #900597

#TimeUsernameProblemLanguageResultExecution timeMemory
900597HamzaTEkoeko (COCI21_ekoeko)C++14
0 / 110
1 ms348 KiB
//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 ::
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...