Submission #816415

# Submission time Handle Problem Language Result Execution time Memory
816415 2023-08-09T05:02:00 Z christinelynn Ekoeko (COCI21_ekoeko) C++17
0 / 110
1 ms 468 KB
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n, ans=0; cin >> n;
  vector<int> pos(26, -1), poss(26);
  for(int i=0; i<n; i++) {
    char c; cin >> c;
    pos[c-'a']=i;
  }
  string s; cin >> s;
  for(int i=0; i<n; i++) poss[s[i]-'a']=i;
  for(int i=0; i<26; i++) {
    if(pos[i]==-1) continue;
    ans+=abs(pos[i]-poss[i]);
    poss[s[pos[i]]]=poss[i];
  }
  cout << ans << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -