QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#573066 | #9310. Permutation Counting 4 | 1457 | WA | 0ms | 3848kb | C++14 | 857b | 2024-09-18 17:13:52 | 2024-09-18 17:13:57 |
Judging History
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'