| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 670529 | MilosMilutinovic | Group Photo (JOI21_ho_t3) | C++14 | 5038 ms | 324 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
--h[i];
}
vector<int> pos(n);
for (int i = 0; i < n; i++) {
pos[h[i]] = i;
}
vector<int> p(n);
iota(p.begin(), p.end(), 0);
int ans = 1e9;
do {
bool valid = true;
for (int i = 0; i + 1 < n; i++) {
valid = (valid & (p[i] < p[i + 1] || p[i] == p[i + 1] + 1));
}
if (!valid) {
continue;
}
int nans = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (pos[p[i]] > pos[p[j]]) {
nans += 1;
}
}
}
ans = min(ans, nans);
} while (next_permutation(p.begin(), p.end()));
cout << ans << '\n';
return 0;
}
| # | 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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
