5000
1333 1
1333 2
1333 3
1333 4
1333 5
1333 6
1333 7
1333 8
1333 9
1333 10
1333 11
1333
<53788 bytes omitted>
用户输出
24975004
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#24237 | #1144. ddd和猴子 | Wrong Answer | 30 | 1574 ms | 1888 K | C++ 17 / 1.1 K | YangDavid | 2020-04-23 0:08:06 |
/*
* Author : YangDavid
* Created Time : 2020年04月22日 星期三 23时55分55秒
*/
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template <typename... Args>
auto ndim(size_t sz0, Args&&... args) {
if constexpr (sizeof...(args) == 1)
return vector(sz0, args...);
else
return vector(sz0, ndim(args...));
}
const int MAXN = 105501;
vector<int> G[MAXN];
int n, deg[MAXN];
int main() {
scanf("%d", &n);
set<pii, greater<pii>> st;
rep(i, n - 1) {
static int x, y;
scanf("%d%d", &x, &y);
G[x].push_back(y);
G[y].push_back(x);
deg[x]++, deg[y]++;
}
rep(i, n) st.emplace(deg[i], i);
ll ans = 0;
while (!st.empty()) {
auto [dg, v] = *st.begin();
if (dg <= 3)
break;
ans += 1LL * dg * (dg - 1) - 2 * dg;
st.erase(st.begin());
for (auto g : G[v]) {
st.erase(pii(deg[g], g));
st.insert(pii(--deg[g], g));
}
}
printf("%lld\n", ans);
return 0;
}
5000
1333 1
1333 2
1333 3
1333 4
1333 5
1333 6
1333 7
1333 8
1333 9
1333 10
1333 11
1333
<53788 bytes omitted>
用户输出
24975004
系统信息
Exited with return code 0
5000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
<52684 bytes omitted>
用户输出
0
系统信息
Exited with return code 0
5000
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
<51577 bytes omitted>
用户输出
0
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
5000
1 4514
2 4514
3 4514
4 4514
5 4514
6 4514
7 4514
8 4514
9 4514
10 4514
11 4514
12 4
<52679 bytes omitted>
用户输出
12882454938
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
5000
1 1926
2 1926
3 1926
4 1926
5 1926
6 1926
7 1926
8 1926
9 1926
10 1926
11 1926
12 1
<52679 bytes omitted>
用户输出
7593563178
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
5000
2 1
3 1
4 3
5 3
6 5
7 5
8 3
9 1
10 7
11 2
12 5
13 6
14 8
15 13
16 13
17 7
18 8
<50535 bytes omitted>
用户输出
12474
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
5000
2 1
3 1
4 3
5 4
6 3
7 1
8 4
9 1
10 8
11 7
12 9
13 7
14 8
15 11
16 4
17 1
18 5
<50582 bytes omitted>
用户输出
16424
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0
5000
2 1
3 1
4 3
5 4
6 2
7 6
8 6
9 7
10 1
11 7
12 10
13 1
14 8
15 2
16 7
17 13
18 1
<50545 bytes omitted>
用户输出
15220
Special Judge 信息
Files user_out and answer differ
系统信息
Exited with return code 0