QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#667033 | #7158. Carnival General | Khiem# | 0 | 0ms | 0kb | C++14 | 1017b | 2024-10-22 20:49:29 | 2024-10-22 20:49:43 |
answer
#include <bits/stdc++.h>
#define z exit(0)
using namespace std;
const int N = 1005;
vector<int> g[N];
int a[N];
signed main(){
int n; scanf("%d", &n);
for(int i = 1; i<n; ++i){
for(int j = 0; j<i; ++j) scanf("%d", a+j);
int sz = i/2 + (i&1);
for(int j = 0; j<sz; ++j){
int u = i, v = a[j];
g[u].push_back(v); g[v].push_back(u);
}
}
int j = n-2;
for(int i = 0; i<n; ++i) sort(g[i].begin(), g[i].end());
for(int v: g[j]) g[v].erase(find(g[v].begin(), g[v].end(), j));
for(int t = 0; t<n; ++t){
printf("%d ", j);
int sz = g[j].size(), ls;
if(!(t&1)){
for(int i = 0; i<sz && g[j][i] < j; ++i) ls = g[j][i];
}else{
for(int i = sz-1; i>=0 && g[j][i] > j; --i) ls = g[j][i];
}
j = ls;
for(int v: g[j]){
auto itr = find(g[v].begin(), g[v].end(), j);
if(itr != g[v].end()) g[v].erase(itr);
}
}
}
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
2 0
output:
result:
Subtask #2:
score: 0
Runtime Error
Test #6:
score: 0
Runtime Error
input:
2 0
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #12:
score: 0
Runtime Error
input:
2 0
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%