QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#689307 | #9310. Permutation Counting 4 | LETTER | WA | 0ms | 3620kb | C++20 | 907b | 2024-10-30 16:18:47 | 2024-10-30 16:18:50 |
Judging History
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'