QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#667227 | #7158. Carnival General | Khiem# | 0 | 0ms | 0kb | C++14 | 1.7kb | 2024-10-22 21:43:17 | 2024-10-22 21:43:50 |
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);
}
}
if(n&1){
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);
}
}
}else{
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){
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);
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
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%