QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#680748 | #8333. Gift | AuroraKelsey | WA | 0ms | 8488kb | C++14 | 1.7kb | 2024-10-26 22:29:43 | 2024-10-26 22:29:44 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <queue>
using namespace std;
const int N = 2e5;
int du[N];
vector<int> G[N];
#define LL long long
bool vis[N];
int cnt;
int n;
vector<int> huan;
void tuopu()
{
queue<int> q;
for (int i = 1; i <= n; i++)
{
if (du[i] == 1)
{
q.push(i);
vis[i] = 1;
}
}
while (!q.empty())
{
int x = q.front();
q.pop();
for (auto y : G[x])
{
du[y]--;
if (du[y] == 1)
{
q.push(y);
vis[y] = 1;
}
}
}
for (int i = 1; i <= n; i++)
{
if (!vis[i])
{
huan.push_back(i);
}
}
}
int main()
{
scanf("%d", &n);
int spe = 0;
for (int i = 1, x, y; i <= n; i++)
{
scanf("%d %d", &x, &y);
du[x]++;
du[y]++;
G[x].emplace_back(y);
G[y].emplace_back(x);
if (du[x] > 4)
{
spe = x;
}
if (du[y] > 4)
{
spe = y;
}
}
// 无度数大于4的点
tuopu();
if (!spe)
{
// 找环
tuopu();
printf("%lld", (LL)huan.size() * (LL)n);
}
else
{
cout << spe << endl;
LL ans_cir = 0;
for (auto y : G[spe])
{
if (!vis[y])
{
ans_cir++;
// cout << y << endl;
}
}
printf("%lld", ans_cir * (LL)(n - 1));
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 8488kb
input:
6 1 2 1 3 1 4 1 5 1 6 2 3
output:
1 10
result:
wrong answer 1st numbers differ - expected: '10', found: '1'