Submission #1163408

#TimeUsernameProblemLanguageResultExecution timeMemory
1163408jmuzhenEkoeko (COCI21_ekoeko)C++20
0 / 110
1 ms612 KiB
#include<bits/stdc++.h> using namespace std; #define cerr if(false) cerr int main() { int n; cin >> n; string s; cin >> s; long long ans = 0; for (int i = 0; i < n; i++) { int j = i + n; char c = s[i]; if (s[j] == c) continue; // look for first occurrence of c after i (j?) int k = i+1; while (k < 2 * n) { if (s[k] == c) break; k++; } cerr << c << " : " << j << " <-> " << k << endl; while (k > j) { swap(s[k], s[k-1]); ans++; k--; } } cout << ans << endl; }
#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...