QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#689307#9310. Permutation Counting 4LETTERWA 0ms3620kbC++20907b2024-10-30 16:18:472024-10-30 16:18:50

Judging History

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

  • [2024-10-30 16:18:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-10-30 16:18:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// #define int ll
void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> g(n + 1);
    for (int i = 1; i <= n; i++)
    {
        int l, r;
        cin >> l >> r;
        l--;
        g[l].push_back(r);
    }
    vector<int> vis(n + 1);
    int cnt = 0;
    auto dfs = [&](auto self, int u) -> void {
        if (vis[u] == 0)
        {
        	cerr<<u<<"\n";
            vis[u] = 1;
            cnt++;
            for (auto v : g[u])
            {
                self(self, v);
            }
        }
    };
    dfs(dfs, 0);
    if (cnt == n + 1)
    {
        cout << 1 << "\n";
    }
    else
    {
        cout << 0 << "\n";
    }
}
signed main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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'