QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572673#9310. Permutation Counting 4jiujiuCompile Error//C++201.1kb2024-09-18 15:54:072024-09-18 15:54:08

Judging History

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

  • [2024-09-18 15:54:08]
  • 评测
  • [2024-09-18 15:54:07]
  • 提交

answer

#include <bits/stdc++.h>
using ld = long double;
using i64 = long long;

#define NO std::cout << "No\n"
#define YES std::cout << "Yes\n"
#define all(x) x.begin(), x.end()

// std::default_random_engine Rand;
// std::uniform_int_distribution<int> r1(1, 10);
// constexpr int d[4][2] = {-1, 0, 0, 1, 1, 0, 0, -1};
void solve() {
	int n;
	std::cin >> n;
	std::vector<std::vector<int>> g(n + 1);


	for (int i = 0; i < n; i++) {
		int a, b;
		std::cin >> a >> b;
		a -= 1;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	std::vector<int> vis(n + 1);
	int sum = 0;
	auto dfs = [&](auto &dfs, int x) {
		if(!vis[x])vis[x] = 1,sum++;

		for(auto y : g[x]){
			if(!vis[y])
			dfs(dfs, y);
		} 
	};
	dfs(0);
	if(sum == n + 1){
		std::cout << "1\n";
	}else{
		std::cout << "0\n";
	}
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    // Rand.seed(time(0));

    int _ = 1;

    std::cin >> _;
    // scanf("%ld",&_);
    // std::cout<<std::fixed<<std::setprecision(2);

    while (_--) {
        solve();
    }
    return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:36:12: error: no match for call to ‘(solve()::<lambda(auto:54&, int)>) (int)’
   36 |         dfs(0);
      |         ~~~^~~
answer.code:28:20: note: candidate: ‘template<class auto:54> solve()::<lambda(auto:54&, int)>’
   28 |         auto dfs = [&](auto &dfs, int x) {
      |                    ^
answer.code:28:20: note:   template argument deduction/substitution failed:
answer.code:36:12: note:   candidate expects 2 arguments, 1 provided
   36 |         dfs(0);
      |         ~~~^~~