QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#568835#9310. Permutation Counting 4Master640WA 8ms27840kbC++14868b2024-09-16 18:45:252024-09-16 18:45:26

Judging History

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

  • [2024-09-18 14:56:40]
  • hack成功,自动添加数据
  • (/hack/835)
  • [2024-09-18 14:41:06]
  • hack成功,自动添加数据
  • (/hack/831)
  • [2024-09-17 12:14:52]
  • hack成功,自动添加数据
  • (/hack/825)
  • [2024-09-16 18:45:26]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:27840kb
  • [2024-09-16 18:45:25]
  • 提交

answer

//
// Created by 35263 on 2024/9/16.
//
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
vector<int>g[maxn];
int n,m,l,r,flag,vis[maxn];
void update(){
    for(int i=1;i<=n;i++)g[i].clear(),vis[i]=0;
    flag=false;
}
void dfs(int x,int fa){
    vis[x]=1;
    if(flag)return;
    for(auto v:g[x]){
        if(v==fa)continue;
        if(vis[v]){
            flag=true;
            return;
        }
        dfs(v,x);
    }
}
void init(){
    cin>>n;
    update();
    for(int i=1;i<=n;i++)cin>>l>>r,g[l].push_back(r),g[r].push_back(l);
    dfs(1,0);
    if(flag){
        cout<<0<<endl;
    }
    else{
        cout<<1<<endl;
    }
}
int main(){
    int t;
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>t;
    while(t--){
        update();
        init();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 8ms
memory: 27840kb

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
1
0

result:

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