# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
580183 | Josia | Boarding Passes (BOI22_passes) | C++14 | 1 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
string s; cin >> s;
int n = s.size();
vector<vector<int>> groupsAlph(26);
for (int i = 0; i<n; i++) {
groupsAlph[s[i]].push_back(i);
}
vector<vector<int>> groups;
for (auto i: groupsAlph) {
if (i.size()) groups.push_back(i);
}
double res = 1e18;
do {
vector<bool> isset(n);
double blubblubres = 0; // with this permutation of groups
for (int i = 0; i<groups.size(); i++) {
vector<int> pfs = {0};
for (int j = 0; j<n; j++) pfs.push_back(isset[j] + pfs.back());
double blubres = 1e18; // find best offset for this group and current situation
for (int j = 0; j<groups[i].size(); j++) {
int n1 = j;
int n2 = groups[i].size()-j;
double tmpres = ((n1-1)*n1 + (n2-1)*n2)/4.0; // current selected offset
for (int k = 0; k<n1; k++) {
tmpres += pfs[groups[i][k]+1];
}
for (int k = n1; k<groups[i].size(); k++) {
tmpres += pfs.back() - pfs[groups[i][k]];
}
blubres = min(blubres, tmpres);
}
blubblubres += blubres;
for (int j: groups[i]) isset[j] = 1;
}
res = min(res, blubblubres);
} while (next_permutation(groups.begin(), groups.end()));
cout << setprecision(100) << res << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |