QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#751736 | #8333. Gift | SATSKY | WA | 0ms | 3612kb | C++17 | 1.0kb | 2024-11-15 20:22:54 | 2024-11-15 20:22:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;using ll=long long;const int N=1e6+10;const ll inf=1e17;
struct S
{
int n;ll ans=0;vector<vector<int>>es;vector<int>u,v,vis,cc,inC,stk,cnt;
bool spr(int x,int lst)
{
if(vis[x]){while(1){int y=stk.back();stk.pop_back();inC[y]=1;if(y==x)return 1;}}
vis[x]=1;stk.push_back(x);for(auto&k:es[x]){int y=u[k]^v[k]^x;if(y!=lst&&spr(y,x))return 1;}
stk.pop_back();return 0;
}
void ini()
{
cin>>n;es.resize(n+1);cc.resize(n+1);vis=inC=u=v=cc;cnt.resize(6,0);
for(int i=1,a,b;i<=n;i++)cin>>a>>b,u[i]=a,v[i]=b,
cc[a]++,cc[b]++,es[a].push_back(i),es[b].push_back(i);
for(int i=1;i<=n;i++)cnt[cc[i]]++;spr(1,0);
for(int i=1;i<=n;i++)
{
int a=u[i],b=v[i];if(!inC[a]||!inC[b])continue;
cnt[cc[a]]--;cnt[cc[a]-1]++;cnt[cc[b]]--;cnt[cc[b]-1]++;if(!cnt[5])ans+=n-cnt[4];
cnt[cc[a]]++;cnt[cc[a]-1]--;cnt[cc[b]]++;cnt[cc[b]-1]--;
}
}
void solve()
{
}
};
int main()
{
ios::sync_with_stdio(0);cin.tie(0);
int t=1;//cin>>t;
while(t--){S SS;SS.ini();SS.solve();}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3612kb
input:
6 1 2 1 3 1 4 1 5 1 6 2 3
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements