QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#648462 | #8333. Gift | ucup-team3646# | WA | 1ms | 4116kb | C++20 | 1.5kb | 2024-10-17 19:06:49 | 2024-10-17 19:06:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N;
cin>>N;
vector<vector<ll>> G(N);
vector<int> E(N);
for(int i=0;i<N;i++){
int u,v;
cin>>u>>v;
u--;v--;
G[u].push_back(v);
G[v].push_back(u);
E[u]++;
E[v]++;
}
vector<int> P=E;
vector<bool> LOOP(N,1);
queue<int> Q;
for(int i=0;i<N;i++){
if(P[i]==1){
Q.push(i);
}
}
while(!Q.empty()){
int p=Q.front();
Q.pop();
if(!LOOP[p])continue;
LOOP[p]=0;
for(int v:G[p]){
P[v]--;
if(P[v]==1){
Q.push(v);
}
}
}
vector<int> CNT(N+1,0);
for(int i=0;i<N;i++)CNT[E[i]]++;
set<pair<int,int>> seen;
ll an=0;
for(int i=0;i<N;i++){
if(!LOOP[i])continue;
int u=i;
for(auto j:G[i]){
if(LOOP[j]){
int v=j;
if(u>v)swap(u,v);
if(seen.count({u,v}))continue;
seen.insert({u,v});
CNT[E[u]]--;
CNT[E[v]]--;
CNT[E[u]-1]++;
CNT[E[v]-1]++;
if(CNT[5]==0)an+=N-CNT[4];
CNT[E[u]]++;
CNT[E[v]]++;
CNT[E[u]-1]--;
CNT[E[v]-1]--;
}
}
}
cout<<an<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
6 1 2 1 3 1 4 1 5 1 6 2 3
output:
10
result:
ok 1 number(s): "10"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
3 1 3 3 2 2 1
output:
9
result:
ok 1 number(s): "9"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 4116kb
input:
2332 1648 909 1676 2122 1644 1981 1106 1131 1785 239 223 618 335 1662 424 1775 889 1684 1589 52 1406 1747 1600 302 790 2056 1742 464 1706 541 1145 779 2316 833 1645 1439 859 438 1337 136 746 1565 436 1730 2079 2145 1583 1940 917 1549 1863 507 1266 367 1890 2230 13 2113 492 2109 120 1122 815 1111 134...
output:
7723584
result:
wrong answer 1st numbers differ - expected: '5438224', found: '7723584'