比赛 |
不平凡的世界 |
评测结果 |
AAAAATTTTT |
题目名称 |
不平凡的许愿树 |
最终得分 |
50 |
用户昵称 |
pppoooiiizzy |
运行时间 |
27.662 s |
代码语言 |
C++ |
内存使用 |
79.62 MiB |
提交时间 |
2015-11-05 10:45:43 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<set>
#include<map>
#include<deque>
#include<list>
#include<ctime>
#include<cstdlib>
#include<string>
#include<sstream>
#include<iomanip>
const int maxn = 5000 + 100;
using namespace std;
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define drep(i, j, k) for(int i = j; i >= k; i--)
#define INF 0x3fffffff
#define LL long long
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar(); }
while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
return x * f;
}
int d[maxn][maxn], Ar, Sa, m, n;
int sum, cnt, tot, ans;
void init()
{
n = read();
rep(i, 1, n - 1) {
Ar = read(), Sa = read();
d[Ar][Sa] = d[Sa][Ar] = 1;
}
}
int main()
{
freopen("hopetree.in", "r", stdin);
freopen("hopetree.out", "w", stdout);
memset(d, 0x3f, sizeof(d));
init();
rep(k, 1, n)
rep(i, 1, n)
rep(j, 1, n)
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
rep(i, 1, n)
rep(j, i, n)
rep(k, j, n) {
if(d[i][j] == d[i][k] && d[i][j] == d[k][j] && d[i][k] == d[k][j]
&& i != j && j != k && i != k && d[i][j] != 0x3f3f3f3f) cnt++;
}
cout<<cnt % 338 + 1<<" "<<(cnt + 233) % 338 + 1<<endl;
}