답안 #1012369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012369 2024-07-02T04:29:11 Z hengliao Swap (BOI16_swap) C++17
10 / 100
427 ms 262144 KB
#include<bits/stdc++.h>
#include <chrono>
#include <random>
using namespace std;

#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>
typedef long long ll;

const ll mxN=2e5+5;

ll n;
ll a[mxN];

void solve(){
	vll tep(n);
    for(ll i=1;i<=n;i++){
        tep[i-1]=a[i];
    }
    vector<vll> ans;
    for(ll mask=0;mask<(1LL<<n);mask++){
        if(mask&1) continue;
        vll tep2=tep;
        for(ll j=1;j<n;j++){
            if(mask&(1LL<<j)){
                swap(tep2[(j+1)/2-1], tep2[j]);
            }
        }
        ans.pb(tep2);
    }
    sort(ans.begin(), ans.end());
    for(auto &it:ans[0]){
        cout<<it<<' ';
    }
    cout<<'\n';
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }

	solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 102892 KB Output is correct
2 Correct 402 ms 102888 KB Output is correct
3 Correct 395 ms 102888 KB Output is correct
4 Correct 394 ms 102892 KB Output is correct
5 Correct 384 ms 102880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 102892 KB Output is correct
2 Correct 402 ms 102888 KB Output is correct
3 Correct 395 ms 102888 KB Output is correct
4 Correct 394 ms 102892 KB Output is correct
5 Correct 384 ms 102880 KB Output is correct
6 Runtime error 165 ms 262144 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 102892 KB Output is correct
2 Correct 402 ms 102888 KB Output is correct
3 Correct 395 ms 102888 KB Output is correct
4 Correct 394 ms 102892 KB Output is correct
5 Correct 384 ms 102880 KB Output is correct
6 Runtime error 165 ms 262144 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 102892 KB Output is correct
2 Correct 402 ms 102888 KB Output is correct
3 Correct 395 ms 102888 KB Output is correct
4 Correct 394 ms 102892 KB Output is correct
5 Correct 384 ms 102880 KB Output is correct
6 Runtime error 165 ms 262144 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 102892 KB Output is correct
2 Correct 402 ms 102888 KB Output is correct
3 Correct 395 ms 102888 KB Output is correct
4 Correct 394 ms 102892 KB Output is correct
5 Correct 384 ms 102880 KB Output is correct
6 Runtime error 165 ms 262144 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -