| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1366184 | biserailieva | Carnival (EGOI23_carnival) | C++20 | 51 ms | 2940 KiB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
if(n<=8)
{
vector<vector<int>>V(n);
for(int i=0;i<n-1;i++)
{
for(int j=0;j<i+1;j++)
{
int x;
cin>>x;
if(j>=(i+2)/2)
{
V[i+1].push_back(x);
V[x].push_back(i+1);
}
}
}
int A[n];
for(int i=0;i<n;i++)
{
A[i]=i;
}
bool valid;
do
{
valid=true;
for(int i=0;i+1<n;i++)
{
for(int br : V[A[i]])
{
if(br==A[i+1])
{
valid=false;
}
}
for(int br : V[A[i+1]])
{
if(br==A[i])
{
valid=false;
}
}
}
if(valid)
{
for(int i=0;i<n;i++)
{
cout<<A[i]<<' ';
}
cout<<endl;
return 0;
}
}while(next_permutation(A, A+n));
}
vector<int>V[n];
bool s=true, rev=true;
for(int i=0;i<n-1;i++)
{
vector<int>A;
for(int j=0;j<i+1;j++)
{
int x;
cin>>x;
V[i].push_back(x);
A.push_back(x);
}
sort(A.begin(), A.end());
if(A!=V[i])
{
s=false;
}
reverse(A.begin(), A.end());
if(A!=V[i])
{
rev=false;
}
}
if(rev)
{
for(int i=0;i<n;i++)
{
cout<<i<<' ';
}
cout<<endl;
}
return 0;
}
/*
6
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
5 2 0 3 1 4
5
0
0 1
0 1 2
0 1 2 3
0 - 1 2 3 4
1 - 0 3 4
2 - 0
3 - 0 1
4 - 0 1
4
0
1 0
0 2 1
0 - 1 3
1 - 0 2
2 - 1 3
3 - 0 2
2 0 3 1 4 */| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
