Submission #56210

# Submission time Handle Problem Language Result Execution time Memory
56210 2018-07-10T09:03:18 Z 노영훈(#1580) Swap (BOI16_swap) C++11
10 / 100
1000 ms 560 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=500010, inf=2e9;

int n;
int A[MX], B[MX];

int now[MX];

bool cmp(){
    for(int i=1; i<=n; i++)
        if(now[i]<B[i]) return true;
        else if(now[i]>B[i]) return false;
    return true;
}

void search(int idx=2){
    if(idx>n){
        if(cmp())
            for(int i=1; i<=n; i++) B[i]=now[i];
        return;
    }
    swap(now[idx], now[idx/2]);
    search(idx+1);
    swap(now[idx], now[idx/2]);
    search(idx+1);
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>A[i], B[i]=now[i]=A[i];

    search();

    for(int i=1; i<=n; i++) cout<<B[i]<<' ';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
3 Correct 9 ms 560 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 9 ms 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
3 Correct 9 ms 560 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 9 ms 560 KB Output is correct
6 Execution timed out 1098 ms 560 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
3 Correct 9 ms 560 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 9 ms 560 KB Output is correct
6 Execution timed out 1098 ms 560 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
3 Correct 9 ms 560 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 9 ms 560 KB Output is correct
6 Execution timed out 1098 ms 560 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
3 Correct 9 ms 560 KB Output is correct
4 Correct 9 ms 560 KB Output is correct
5 Correct 9 ms 560 KB Output is correct
6 Execution timed out 1098 ms 560 KB Time limit exceeded
7 Halted 0 ms 0 KB -