# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
535724 | 2022-03-11T03:17:34 Z | sam571128 | Group Photo (JOI21_ho_t3) | C++17 | 1896 ms | 312 KB |
#include <bits/stdc++.h> #define int long long #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; signed main(){ fastio int n; cin >> n; int arr[n], tmp[n], idk[n]; for(auto &x : arr) cin >> x; int ans = 1e18; for(int mask = 0; mask < (1<<n); mask++){ vector<int> v; for(int i = 0;i < n;i++){ if(mask&(1<<i)) v.push_back(i); } for(int i = 0;i < n;i++){ tmp[i] = i+1; } for(int i = 1;i < v.size();i += 2){ reverse(tmp+v[i-1],tmp+v[i]+1); } for(int i = 0;i < n;i++){ for(int j = 0;j < n;j++){ if(tmp[i]==arr[j]) idk[i] = j; } } int cnt = 0; for(int i = 0;i < n;i++){ for(int j = 0;j < i;j++){ if(idk[j] > idk[i]){ cnt++; } } } ans = min(ans,cnt); } cout << ans << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 386 ms | 296 KB | Output is correct |
12 | Correct | 741 ms | 308 KB | Output is correct |
13 | Correct | 868 ms | 308 KB | Output is correct |
14 | Correct | 1896 ms | 312 KB | Output is correct |
15 | Correct | 1697 ms | 296 KB | Output is correct |
16 | Correct | 1736 ms | 308 KB | Output is correct |
17 | Correct | 1525 ms | 300 KB | Output is correct |
18 | Correct | 1630 ms | 304 KB | Output is correct |
19 | Correct | 1775 ms | 308 KB | Output is correct |
20 | Correct | 1689 ms | 300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 386 ms | 296 KB | Output is correct |
12 | Correct | 741 ms | 308 KB | Output is correct |
13 | Correct | 868 ms | 308 KB | Output is correct |
14 | Correct | 1896 ms | 312 KB | Output is correct |
15 | Correct | 1697 ms | 296 KB | Output is correct |
16 | Correct | 1736 ms | 308 KB | Output is correct |
17 | Correct | 1525 ms | 300 KB | Output is correct |
18 | Correct | 1630 ms | 304 KB | Output is correct |
19 | Correct | 1775 ms | 308 KB | Output is correct |
20 | Correct | 1689 ms | 300 KB | Output is correct |
21 | Incorrect | 7 ms | 212 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 386 ms | 296 KB | Output is correct |
12 | Correct | 741 ms | 308 KB | Output is correct |
13 | Correct | 868 ms | 308 KB | Output is correct |
14 | Correct | 1896 ms | 312 KB | Output is correct |
15 | Correct | 1697 ms | 296 KB | Output is correct |
16 | Correct | 1736 ms | 308 KB | Output is correct |
17 | Correct | 1525 ms | 300 KB | Output is correct |
18 | Correct | 1630 ms | 304 KB | Output is correct |
19 | Correct | 1775 ms | 308 KB | Output is correct |
20 | Correct | 1689 ms | 300 KB | Output is correct |
21 | Incorrect | 7 ms | 212 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 386 ms | 296 KB | Output is correct |
12 | Correct | 741 ms | 308 KB | Output is correct |
13 | Correct | 868 ms | 308 KB | Output is correct |
14 | Correct | 1896 ms | 312 KB | Output is correct |
15 | Correct | 1697 ms | 296 KB | Output is correct |
16 | Correct | 1736 ms | 308 KB | Output is correct |
17 | Correct | 1525 ms | 300 KB | Output is correct |
18 | Correct | 1630 ms | 304 KB | Output is correct |
19 | Correct | 1775 ms | 308 KB | Output is correct |
20 | Correct | 1689 ms | 300 KB | Output is correct |
21 | Incorrect | 7 ms | 212 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |