Submission #1136254

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11362542025-01-15 12:06:43byunjaewooSwap (BOI16_swap)C++20
100 / 100
594 ms180620 KiB
#include <bits/stdc++.h>
using namespace std;
const int N=200010;
int n, a[N];
vector<int> c[N];
vector<vector<int>> d[N];
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n;
for(int i=1; i<=n; i++) cin>>a[i];
c[1].push_back(a[1]);
for(int i=1; i<=(n-1)/2; i++) {
sort(c[i].begin(), c[i].end()), c[i].erase(unique(c[i].begin(), c[i].end()), c[i].end());
for(int xx:c[i]) {
int x=xx, y=a[2*i], z=a[2*i+1];
if(x<y && x<z) {
c[2*i].push_back(y), c[2*i+1].push_back(z);
continue;
}
if(y<x && y<z) {
swap(x, y);
c[2*i].push_back(y), c[2*i+1].push_back(z);
continue;
}
c[2*i].push_back(x), c[2*i+1].push_back(y), c[2*i].push_back(y), c[2*i+1].push_back(x);
}
}
for(int i=1; i<=n; i++) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...