QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#174152#6634. Central SubsetKlaus26#Compile Error//C++201.2kb2023-09-10 04:45:292023-09-10 04:45:30

Judging History

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

  • [2023-09-10 04:45:30]
  • 评测
  • [2023-09-10 04:45:29]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "../debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



const int N = 2e5+10;

vector<int> g[N];
int vis[N];

int n, m, lim;

void cl(){
	for(int i=1; i<=n; i++){
		g[i].clear();
		vis[i] = 0;
	}
}
bool visitado2[N+3];
vector<int>cuales;
void dfs(int u, int dis){
	if(dis > lim) return;
	visitado2[u] = true;
	cuales.pb(u);
	vis[u] = 1;
	for(auto& v : g[u]){
		if(visitado2[v])continue;
		dfs(v,u,dis+1);	
	}
	
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin>>T;
	memset(visitado2, false, sizeof visitado2);
	while(T--){
		cin>>n>>m;
		lim = sqrt(n);
		while(true){
			if(lim * lim >= n )break;
			lim++;
		}
		debug(lim);
		for(int i=0; i<m; i++){
			int u, v;
			cin>>u>>v;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		vector<int> ans;
		for(int i=1; i<=n; i++){
			if(vis[i])continue;
			ans.push_back(i);
			dfs(i,0);
			for(auto i : cuales)visitado2[i] = false;
			cuales.clear();
		}
		cout<<ans.size()<<'\n';
		for(auto& i : ans) cout<<i<<' ';
		cout<<'\n';
		cl();
	}
	return 0;
}

詳細信息

answer.code: In function ‘void dfs(int, int)’:
answer.code:32:16: error: ‘class std::vector<int>’ has no member named ‘pb’
   32 |         cuales.pb(u);
      |                ^~
answer.code:36:20: error: too many arguments to function ‘void dfs(int, int)’
   36 |                 dfs(v,u,dis+1);
      |                 ~~~^~~~~~~~~~~
answer.code:29:6: note: declared here
   29 | void dfs(int u, int dis){
      |      ^~~