# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1003790 | 2024-06-20T17:50:47 Z | vjudge1 | Ekoeko (COCI21_ekoeko) | C++17 | 20 ms | 13804 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); map<char,set<int>> pos; for(int i=0; i<2*n; i++){ if(mp[s[i]]<cnt[s[i]]/2){ mp[s[i]]++; cnt1++; trans[i]=cnt1; pos[s[i]].insert(i+1); } } for(int i=0; i<2*n; i++) if(!trans[i]){ assert(pos[s[i]].size()>0); trans[i] = (*pos[s[i]].begin())+n; pos[s[i]].erase(pos[s[i]].begin()); } // for(int x : trans) cout << x << " "; // cout << endl; int ans=0; for(int i=2*n-1; i>0; i--){ ans += query(trans[i]-1); upd(trans[i]); } cout << ans << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 6 ms | 3164 KB | Output is correct |
3 | Correct | 14 ms | 5864 KB | Output is correct |
4 | Runtime error | 20 ms | 13804 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 6 ms | 3164 KB | Output is correct |
3 | Correct | 14 ms | 5864 KB | Output is correct |
4 | Runtime error | 20 ms | 13804 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 6 ms | 3164 KB | Output is correct |
3 | Correct | 14 ms | 5864 KB | Output is correct |
4 | Runtime error | 20 ms | 13804 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 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 | 444 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 428 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 6 ms | 3164 KB | Output is correct |
3 | Correct | 14 ms | 5864 KB | Output is correct |
4 | Runtime error | 20 ms | 13804 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |