# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
258569 | 2020-08-06T07:14:21 Z | 문홍윤(#5064) | Swap (BOI16_swap) | C++17 | 1000 ms | 384 KB |
#include <bits/stdc++.h> #define eb emplace_back #define mp make_pair #define F first #define S second #define all(x) x.begin(), x.end() #define svec(x) sort(x.begin(), x.end()) #define press(x) x.erase(unique(x.begin(), x.end()), x.end()) #define lb(x, v) lower_bound(x.begin(), x.end(), v) #define ub(x, v) upper_bound(x.begin(), x.end(), v) using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; typedef pair<int, LL> pil; typedef pair<LL, int> pli; const LL llinf=2000000000000000000; const LL mod1=1000000007; const LL mod2=998244353; const int inf=2000000000; int ans[30], nw[30]; int n; void dfs(int lv){ if(lv>n){ bool flg=false; for(int i=1; i<=n; i++){ if(nw[i]<ans[i]){ flg=true; break; } if(nw[i]>ans[i])break; } if(flg){ for(int i=1; i<=n; i++)ans[i]=nw[i]; } return; } dfs(lv+1); swap(nw[lv/2], nw[lv]); dfs(lv+1); swap(nw[lv/2], nw[lv]); } int main(){ scanf("%d", &n); for(int i=1; i<=n; i++)scanf("%d", &nw[i]); for(int i=1; i<=n; i++)ans[i]=nw[i]; dfs(2); for(int i=1; i<=n; i++)printf("%d ", ans[i]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 4 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 4 ms | 256 KB | Output is correct |
6 | Execution timed out | 1087 ms | 256 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 4 ms | 256 KB | Output is correct |
6 | Execution timed out | 1087 ms | 256 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 4 ms | 256 KB | Output is correct |
6 | Execution timed out | 1087 ms | 256 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 4 ms | 256 KB | Output is correct |
6 | Execution timed out | 1087 ms | 256 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |