QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#698557#8333. Giftsdmrlh#WA 2ms9816kbC++141.2kb2024-11-01 20:28:112024-11-01 20:28:12

Judging History

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

  • [2024-11-01 20:28:12]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9816kb
  • [2024-11-01 20:28:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld%lld",&x,&y)
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pf(x) printf("%lld",x)
#define pii pair<int,int> 
#define f first 
#define s second
#define int long long



//
const int N = 1e6+10;
int h[N],e[N],ne[N],idx;
int dd,st[N];
int res,ru[N],sum;
bool dfs(int u,int fa)
{
	st[u]=1;
	for(int i=h[u];~i;i=ne[i])
	{
		int j=e[i];
		if(j==fa) continue;
		if(st[j])
		{
			if(ru[j]-1==3) sum++;
			if(ru[u]-1==3) sum++;
			sum+=res;
			dd=j;
			return 0;
		}
		if(!dfs(j,u))
		{
			if(dd==u){
				cout<<sum<<endl;
				exit(0);
			}
			int now=0;
			if(ru[j]-1==3) sum++;
			if(ru[u]-1==3) sum++;
			sum+=res;
			return 0;
		}
	}
	return 1;
}
void add(int a,int b)
{
	ne[idx]=h[a],e[idx]=b,h[a]=idx++;
}
//

//



void solve()
{
	int m;
	cin>>m;
	res=m;
	for(int i=1;i<=m;i++) h[i]=-1;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		add(a,b);
		add(b,a);
		ru[a]++;
		ru[b]++;
	}
	
	for(int i=1;i<=m;i++)
		if(ru[i]>=4) res--;
	dfs(1,-1);
}
signed main()
{
	IOS;
	int _=1;
	while(_--)
		solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 9816kb

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: -100
Wrong Answer
time: 2ms
memory: 9756kb

input:

3
1 3
3 2
2 1

output:

6

result:

wrong answer 1st numbers differ - expected: '9', found: '6'