# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
258591 | 2020-08-06T07:50:11 Z | 반딧불(#5073) | Swap (BOI16_swap) | C++17 | 1000 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; int arr[200002]; vector<int> ans; bool cmp(vector<int> s, vector<int> t){ for(int i=0; i<n; i++){ if(s[i] < t[i]) return true; if(s[i] > t[i]) return false; } return false; } void dfs(int i){ if(i==n+1){ if(ans.empty()) ans = vector<int> (arr+1, arr+n+1); else if(cmp(vector<int> (arr+1, arr+n+1), ans)) ans = vector<int> (arr+1, arr+n+1); return; } if(i==n){ bool swp = 0; if(arr[i/2] > arr[i]) swap(arr[i/2], arr[i]), swp = 1; dfs(i+1); if(swp) swap(arr[i/2], arr[i]); return; } int tmin = min({arr[i/2], arr[i], arr[i+1]}); if(tmin == arr[i/2]) dfs(i+2); else if(tmin == arr[i]){ swap(arr[i/2], arr[i]); dfs(i+2); swap(arr[i/2], arr[i]); } else{ swap(arr[i/2], arr[i+1]); dfs(i+2); swap(arr[i], arr[i+1]); dfs(i+2); swap(arr[i], arr[i+1]); swap(arr[i/2], arr[i+1]); } } int main(){ scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", &arr[i]); dfs(2); for(auto &x: ans) printf("%d ", x); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 21 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 21 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Execution timed out | 1094 ms | 384 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 21 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Execution timed out | 1094 ms | 384 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 21 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Execution timed out | 1094 ms | 384 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |