# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
342912 | 2021-01-03T08:11:47 Z | urd05 | Village (BOI20_village) | C++14 | 49 ms | 500 KB |
#include <bits/stdc++.h> using namespace std; int dist[10][10]; const int INF=10000; vector<int> small(10); vector<int> big(10); int main(void) { int n; scanf("%d",&n); for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { dist[i][j]=INF; } dist[i][i]=0; } for(int i=1;i<n;i++) { int u,v; scanf("%d %d",&u,&v); u--; v--; dist[u][v]=1; dist[v][u]=1; } for(int k=0;k<n;k++) { for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]); } } } vector<int> v; for(int i=0;i<n;i++) { v.push_back(i); } int val=1; for(int i=1;i<=n;i++) { val*=i; } int mini=INF; int maxi=-INF; for(int i=0;i<val;i++) { int sum=0; next_permutation(v.begin(),v.end()); bool flag=true; for(int j=0;j<n;j++) { if (v[j]==j) { flag=false; break; } sum+=dist[j][v[j]]; } if (!flag) { continue; } if (sum<mini) { mini=sum; for(int j=0;j<n;j++) { small[j]=v[j]; } } if (sum>maxi) { maxi=sum; for(int j=0;j<n;j++) { big[j]=v[j]; } } } printf("%d %d\n",mini,maxi); for(int i=0;i<n;i++) { printf("%d ",small[i]+1); } printf("\n"); for(int i=0;i<n;i++) { printf("%d ",big[i]+1); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 5 ms | 364 KB | Output is correct |
10 | Correct | 48 ms | 372 KB | Output is correct |
11 | Correct | 49 ms | 372 KB | Output is correct |
12 | Correct | 49 ms | 364 KB | Output is correct |
13 | Correct | 49 ms | 364 KB | Output is correct |
14 | Correct | 49 ms | 364 KB | Output is correct |
15 | Correct | 49 ms | 364 KB | Output is correct |
16 | Correct | 48 ms | 364 KB | Output is correct |
17 | Correct | 49 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 23 ms | 500 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 5 ms | 364 KB | Output is correct |
10 | Correct | 48 ms | 372 KB | Output is correct |
11 | Correct | 49 ms | 372 KB | Output is correct |
12 | Correct | 49 ms | 364 KB | Output is correct |
13 | Correct | 49 ms | 364 KB | Output is correct |
14 | Correct | 49 ms | 364 KB | Output is correct |
15 | Correct | 49 ms | 364 KB | Output is correct |
16 | Correct | 48 ms | 364 KB | Output is correct |
17 | Correct | 49 ms | 364 KB | Output is correct |
18 | Runtime error | 23 ms | 500 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
19 | Halted | 0 ms | 0 KB | - |