제출 #15814

#제출 시각아이디문제언어결과실행 시간메모리
15814jihoon버블 정렬 (OJUZ10_bubblesort)C++98
0 / 100
47 ms65536 KiB
#include<cstdio> #include<deque> using namespace std; int n,k; deque<int> tree[100001]; int su[100001]; int sons[100001]; int head; void bubble(int parent){ int i; for(i=0;i<sons[parent];i++){ bubble(tree[parent][i]); } if(sons[parent]<2) return; head=tree[parent][0]; for(i=1;i<sons[parent];i++){ if(su[head]>su[tree[parent][i]]){ tree[head].push_back(tree[parent][i]); }else{ tree[tree[parent][i]].push_front(head); head=tree[parent][i]; } sons[head]++; } tree[parent].resize(1); tree[parent][0]=head; sons[parent]=1; } void aprint(int parent){ int i; for(i=0;i<sons[parent];i++){ aprint(tree[parent][i]); } if(parent>0) printf("%d ",su[parent]); } int main(){ int i; scanf("%d %d",&n,&k); for(i=1;i<=n;i++){ scanf("%d",&su[i]); tree[0].resize(n); tree[0][i-1]=i; } sons[0]=n; for(i=0;i<k;i++) bubble(0); aprint(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...