QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#573066#9310. Permutation Counting 41457WA 0ms3848kbC++14857b2024-09-18 17:13:522024-09-18 17:13:57

Judging History

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

  • [2024-09-18 17:13:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2024-09-18 17:13:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define NO cout<<"No"<<endl
#define YES cout<<"Yes"<<endl
#define all(a) a.begin(),a.end()
#define endl '\n'
#define pb push_back
#define mo 1000000007
#define MO 998244353

const int N = 1e6+1;
const int M = 2e3+1;

void solve()
{
	int n,sum=0;
	cin>>n;
	vector<int> e[n+1],vis(n+1);
	for(int i=1;i<=n;i++)
	{
		int u,v;
		cin>>u>>v;
		u--;
		e[u].pb(v);
		e[v].pb(u);
	}
	function<void(int)> dfs = [&](int u)
	{
		if(vis[u]==0)
		{
			sum++;
			vis[u]=1;	
		}	
		for(auto p:e[u])
		{
			if(vis[p]==1)dfs(p);
		}
	};
	dfs(0);
	if(sum == n+1)
	{
		cout<<1<<endl;
		return ;
	}
	cout<<0<<endl;
}

signed main()
{
	int _=1;
	cin>>_;
	while(_--)
	{
		solve();
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3848kb

input:

4
5
1 2
1 5
1 2
1 2
2 2
5
1 1
2 4
2 3
5 5
3 4
5
3 5
1 2
3 4
3 5
3 3
5
1 5
1 4
4 5
5 5
1 2

output:

0
0
0
0

result:

wrong answer 2nd words differ - expected: '1', found: '0'