# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
903495 | 2024-01-11T08:09:57 Z | VinhLuu | Swap (BOI16_swap) | C++17 | 124 ms | 4548 KB |
// happy //#pragma GCC optimize("O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> #define int long long //#define ll long long #define fi first #define se second #define pb push_back using namespace std; typedef pair<int,int> pii; typedef tuple<int,int,int> tp; const int N = 1e6 + 5; const int oo = 1e15; const int mod = 1e9 + 7; const int base = 29; // >= so pt pb max int n, a[N], b[N], p[N], f[N][28]; vector<int> kq; bool comp(vector<int> &x, vector<int> &y){ for(int i = 0; i < x.size(); i ++) if(x[i] < y[i]) return 1; else if(x[i] > y[i]) return 0; return 1; } void sub1(){ int full = (1 << (n - 1)) - 1; for(int msk = 0; msk <= full; msk ++){ for(int i = 1; i <= n; i ++) b[i] = a[i]; for(int i = 1; i < n; i ++) if(msk & (1 << (i - 1))) swap(b[i + 1], b[(i + 1)/2]); vector<int> vr; for(int i = 1; i<= n; i ++) vr.pb(b[i]); if(kq.empty() || !comp(kq, vr)) kq = vr; } for(auto j : kq) cout << j << " "; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "v" if(fopen(task ".inp","r")){ freopen(task ".inp","r",stdin); freopen(task ".out","w",stdout); } cin >> n; for(int i = 1; i <= n; i ++) cin >> a[i]; sub1(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 4444 KB | Output is correct |
2 | Correct | 111 ms | 4544 KB | Output is correct |
3 | Correct | 119 ms | 4540 KB | Output is correct |
4 | Correct | 124 ms | 4548 KB | Output is correct |
5 | Correct | 108 ms | 4540 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 4444 KB | Output is correct |
2 | Correct | 111 ms | 4544 KB | Output is correct |
3 | Correct | 119 ms | 4540 KB | Output is correct |
4 | Correct | 124 ms | 4548 KB | Output is correct |
5 | Correct | 108 ms | 4540 KB | Output is correct |
6 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 4444 KB | Output is correct |
2 | Correct | 111 ms | 4544 KB | Output is correct |
3 | Correct | 119 ms | 4540 KB | Output is correct |
4 | Correct | 124 ms | 4548 KB | Output is correct |
5 | Correct | 108 ms | 4540 KB | Output is correct |
6 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 4444 KB | Output is correct |
2 | Correct | 111 ms | 4544 KB | Output is correct |
3 | Correct | 119 ms | 4540 KB | Output is correct |
4 | Correct | 124 ms | 4548 KB | Output is correct |
5 | Correct | 108 ms | 4540 KB | Output is correct |
6 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 4444 KB | Output is correct |
2 | Correct | 111 ms | 4544 KB | Output is correct |
3 | Correct | 119 ms | 4540 KB | Output is correct |
4 | Correct | 124 ms | 4548 KB | Output is correct |
5 | Correct | 108 ms | 4540 KB | Output is correct |
6 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |