QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#573264#9310. Permutation Counting 4nice333WA 0ms3600kbC++171.7kb2024-09-18 17:57:222024-09-18 17:57:26

Judging History

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

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

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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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