QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#667033#7158. Carnival GeneralKhiem#0 0ms0kbC++141017b2024-10-22 20:49:292024-10-22 20:49:43

Judging History

你现在查看的是最新测评结果

  • [2024-10-22 20:49:43]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-10-22 20:49:29]
  • 提交

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%