dmqt
查看原帖
dmqt
947527
Gyf117楼主2024/12/15 17:20

rt。

// Problem: T550031 BCOI的狂欢
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/T550031?contestId=219266
// Memory Limit: 1024 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+7;
int n;
vector<int> v(1);
int a[N];
int main(){
  cin>>n;
  for(int i=1;i<n;++i){
    for(int j=1,x;j<=i;++j){
      cin>>x;
      a[x]=j<=i/2;
    }
    for(auto it=v.begin();it!=v.end();++it){
      if(it==v.begin()){
        if(a[*it]){
          v.insert(it,i);
          goto nxt;
        }
      }
      else{
        if(a[*it] && a[*(it-1)]){
          v.insert(it,i);
          goto nxt;
        }
      }
    }
    v.push_back(i);
    nxt:;
  }
  for(int i:v)cout<<i<<' ';
  return 0;
}
2024/12/15 17:20
加载中...