QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#687932 | #8333. Gift | moyu# | WA | 0ms | 6364kb | C++17 | 1.6kb | 2024-10-29 21:58:59 | 2024-10-29 21:58:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1213;
#define int long long
vector<int>v[N];
queue<int>q;
int rudu[N];
set<int>s;
int rudus[N];
signed main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
int x,y;
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
rudu[x]++;
rudu[y]++;
rudus[x]++;
rudus[y]++;
}
for(int i=1;i<=n;i++){
if(rudu[i]==1){
q.push(i);
}
}
while(!q.empty()){
int u=q.front();
q.pop();
rudu[u]--;
for(int i=0;i<v[u].size();i++){
int j=v[u][i];
rudu[j]--;
if(rudu[j]==1){
q.push(j);
}
}
}
for(int i=1;i<=n;i++){
if(rudu[i]==2){
s.insert(i);
}
}
int ans=0;
bool is_5 = false;
bool is_44 = false;
bool is_4 = false;
set<int> is_54;
int num=0;
for(int j=1;j<=n;j++){
if( s.find(j) != s.end() ){ //s.find(j) != s.end()
if(rudus[j]==5){
is_5 = true;
for(auto k : v[j]){
if(rudus[k] == 4)is_54.insert(k);
}
break;
}
if(rudus[j]==4){
num++;
}
}
}
if(num==2)is_44=true;
if(num>0)is_4=true;
for(int i=1;i<=n;i++){
if(! ( s.find(i) != s.end() ) ){ // 环外
if(is_5)ans+=2;
// else if(is_44)ans+=1;
else if(rudus[i] == 4);
else ans+=s.size();
} else{
if(is_5 ){
if(rudus[i] == 5);
if(is_54.find(i) != is_54.end() ) ans += 1;
else ans+=2;
}
// else if(is_44)ans+=1;
else if(rudus[i] == 4) ans+=2;
else ans+=s.size();
}
}
cout << ans;
}
/*
6
1 2
1 3
1 4
1 5
1 6
2 3
//10
//Page 9 of 20
*/
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6364kb
input:
6 1 2 1 3 1 4 1 5 1 6 2 3
output:
12
result:
wrong answer 1st numbers differ - expected: '10', found: '12'