# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1003797 | 2024-06-20T17:56:29 Z | vjudge1 | Ekoeko (COCI21_ekoeko) | C++17 | 31 ms | 16224 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; } int ord(char c){ return (int)(c-'a'); } signed main(){ int n; cin >> n; string s; cin >> s; vector<int> mp(26,0), cnt(26,0); for(char c : s) cnt[ord(c)]++; int cnt1=0, cnt2=0; vector<int> arr1, arr2; vector<int> trans(2*n); set<int> pos[26]; for(int i=0; i<2*n; i++){ int p = ord(s[i]); if(mp[p]<cnt[p]/2){ mp[p]++; cnt1++; trans[i]=cnt1; pos[p].insert(i+1); } } for(int i=0; i<2*n; i++) if(!trans[i]){ int p = ord(s[i]); assert(pos[p].size()>0); trans[i] = (*pos[p].begin())+n; pos[p].erase(pos[p].begin()); } // 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'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 6 ms | 3188 KB | Output is correct |
3 | Correct | 16 ms | 5868 KB | Output is correct |
4 | Runtime error | 31 ms | 16224 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 6 ms | 3188 KB | Output is correct |
3 | Correct | 16 ms | 5868 KB | Output is correct |
4 | Runtime error | 31 ms | 16224 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 6 ms | 3188 KB | Output is correct |
3 | Correct | 16 ms | 5868 KB | Output is correct |
4 | Runtime error | 31 ms | 16224 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 6 ms | 3188 KB | Output is correct |
3 | Correct | 16 ms | 5868 KB | Output is correct |
4 | Runtime error | 31 ms | 16224 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |