# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003779 |
2024-06-20T17:34:23 Z |
vjudge1 |
Ekoeko (COCI21_ekoeko) |
C++17 |
|
17 ms |
4124 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int maxn = 2e5+5;
int bit[maxn];
void upd(int x){
for(; x<maxn; x+=x&-x) bit[x]++;
}
int query(int x){
int rt=0;
for(; x>0; x-=x&-x) rt+=bit[x];
return rt;
}
signed main(){
int n; cin >> n;
string s; cin >> s;
map<char,int> mp, cnt;
for(char c : s) cnt[c]++;
int cnt1=0, cnt2=0;
vector<int> arr1, arr2;
vector<int> trans(2*n);
for(int i=0; i<2*n; i++){
if(mp[s[i]]<cnt[s[i]]/2) mp[s[i]]++, cnt1++, trans[i]=cnt1;
else cnt2++, trans[i] = n+cnt2;
}
// for(int x : trans) cout << x << " ";
// cout << endl;
int ans=0;
for(int i=0; i<2*n; i++){
ans += i-query(trans[i]-1);
upd(trans[i]);
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
2796 KB |
Output is correct |
4 |
Correct |
8 ms |
4124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
2796 KB |
Output is correct |
4 |
Correct |
8 ms |
4124 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
2796 KB |
Output is correct |
4 |
Correct |
8 ms |
4124 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Incorrect |
17 ms |
4076 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
2796 KB |
Output is correct |
4 |
Correct |
8 ms |
4124 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |