# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
392643 | 2021-04-21T12:12:14 Z | vanic | 관광지 (IZhO14_shymbulak) | C++14 | 201 ms | 1348 KB |
#include <cstdio> #include <cmath> #include <algorithm> #include <cassert> #include <bitset> #include <vector> using namespace std; const int maxn=505; const int inf=1e9; int n; int ms[maxn][maxn]; vector < int > s[maxn]; bitset < maxn > bio; int maksi; int nadji(int x, int y, int dep){ if(x==y){ if(dep==maksi){ return 1; } return 0; } bio[x]=1; int br=0; for(int i=0; i<(int)s[x].size(); i++){ if(!bio[s[x][i]]){ br+=nadji(s[x][i], y, dep+1); } } bio[x]=0; return br; } int main(){ scanf("%d", &n); assert(n<maxn); for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ ms[i][j]=inf; } ms[i][i]=0; } int a, b; for(int i=0; i<n; i++){ scanf("%d%d", &a, &b); a--; b--; s[a].push_back(b); s[b].push_back(a); ms[a][b]=1; ms[b][a]=1; } for(int k=0; k<n; k++){ for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(ms[i][k]+ms[k][j]<ms[i][j]){ ms[i][j]=ms[i][k]+ms[k][j]; } } } } for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ maksi=max(maksi, ms[i][j]); } } int sol=0; for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ if(ms[i][j]==maksi){ sol+=nadji(i, j, 0); bio.reset(); } } } printf("%d\n", sol); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 296 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 304 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 18 ms | 556 KB | Output is correct |
14 | Correct | 196 ms | 1348 KB | Output is correct |
15 | Correct | 201 ms | 1276 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 332 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |