QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#573251 | #9310. Permutation Counting 4 | nice333 | WA | 0ms | 3864kb | C++17 | 1.7kb | 2024-09-18 17:54:56 | 2024-09-18 17:54:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define pii pair<int,int>
#define vec vector
#define vi vec<int>
#define vb vec<bool>
#define vs vec<string>
#define vc vec<char>
#define vvi vec<vec<int>>
#define vsi vec<basic_string<int>>
#define si basic_string<int>
#define asc(vv) sort(vv.begin(),vv.end());
#define desc(vv) sort(vv.rbegin(),vv.rend());
#define eu(vv) vv.erase(unique(vv.begin(),vv.end()),vv.end());
#define gg(nn) vec<basic_string<int>>g(nn+1,basic_string<int>());
#define pq priority_queue
#define cn int n;cin>>n;
#define cs string s;cin>>s;
#define cm int m;cin>>m;
#define ck int k;cin>>k;
#define cq int q;cin>>q;
#define cnm int n,m;cin>>n>>m;
#define cnk int n,k;cin>>n>>k;
#define cnmk int n,m,k;cin>>n>>m>>k;
#define A0 vec<int>a(n);for(int &i:a)cin>>i;
#define A1 vec<int>a(n+1);for(int i=1;i<=n;i++)cin>>a[i];
const int N = 1e6+1;
//const int mod =1e9+7;
//const int mod = 998244353;
void solve(){
int n;
cin >> n;
int sum = 0;
vector<vector<int>> a(n+1);
vector<int> vis(n+1);
for (int i = 1; i <= n;i++)
{
int u, v;
cin >> u >> v;
u--;
a[u].emplace_back(v);
a[v].emplace_back(u);
}
function<void(int)> dfs = [&](int u) {
if(vis[u]==0)
sum++, vis[u] = 1;
for(auto p:a[u]){
if(vis[p]==0)
dfs(p);
}
};
dfs(0);
if(sum==n+1)
cout << 1;
else
cout << 0;
cout << '\n';
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int _=1;
//cin>>_;
for(int i=1;i<=_;i++){
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3864kb
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
result:
wrong answer Unexpected EOF in the participants output