QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751736#8333. GiftSATSKYWA 0ms3612kbC++171.0kb2024-11-15 20:22:542024-11-15 20:22:54

Judging History

你现在查看的是最新测评结果

  • [2024-11-15 20:22:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-11-15 20:22:54]
  • 提交

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