QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#147416#6634. Central Subsetqzez#WA 16ms8492kbC++141.3kb2023-08-23 07:26:092023-08-25 01:29:24

Judging History

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

  • [2023-08-25 01:29:24]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:8492kb
  • [2023-08-23 07:26:09]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e5+5,M=(1<<15)+5,K=14348907+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int n,m,x,y,k,tg[N];vector<int> S[N];
vector<int> ans;
int dfs(int x){
	if(tg[x]) return -1;tg[x]=1;
	int Le=0;
	for(int i:S[x]) Le=max(Le,dfs(i)+1);
	if(Le==k) ans.emplace_back(x),Le=0;
	return Le;
}
void Solve(){
	int i,j;ans.clear();fill(tg+1,tg+n+1,0);for(i=1;i<=n;i++) S[i].clear();
	scanf("%d%d",&n,&m);k=ceil(sqrt(n));
	while(m--) scanf("%d%d",&x,&y),S[x].emplace_back(y),S[y].emplace_back(x);
	dfs(1);
	printf("%d\n",ans.size());
	for(auto i:ans) printf("%d ",i);printf("\n");
}
int main(){
	int t;
	scanf("%d",&t);
	// t=1;                                                                                       
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 8480kb

input:

2
4 3
1 2
2 3
3 4
6 7
1 2
2 3
3 1
1 4
4 5
5 6
6 4

output:

1
2 
1
1 

result:

ok correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 16ms
memory: 8492kb

input:

10000
15 14
13 12
5 4
9 8
11 12
15 14
10 9
14 13
2 3
2 1
6 5
10 11
3 4
7 6
8 7
6 5
2 1
2 4
4 6
2 3
3 5
10 9
8 3
9 4
5 6
5 10
3 2
5 4
2 7
1 2
4 3
2 1
2 1
2 1
2 1
9 8
9 8
5 4
1 2
6 5
3 4
3 2
7 8
7 6
2 1
1 2
14 13
3 10
5 6
2 9
11 4
2 3
2 1
8 7
13 6
5 4
5 12
6 7
4 3
7 14
16 15
2 3
2 1
6 10
6 9
6 4
9 11
...

output:

3
11 7 3 
1
1 
1
2 
0

0

2
6 3 
0

1
4 
2
10 3 
0

3
15 10 5 
1
3 
1
2 
1
5 
0

3
11 7 3 
1
1 
0

1
2 
0

1
2 
1
3 
1
4 
2
5 1 
0

3
11 7 3 
1
1 
2
5 1 
1
1 
0

4
16 11 6 1 
1
2 
1
4 
2
7 4 
0

1
3 
1
2 
1
3 
3
7 6 1 
0

2
8 4 
1
1 
1
3 
1
2 
0

2
6 2 
1
3 
1
3 
2
5 1 
0

3
13 8 3 
1
1 
1
3 
1
4 
0...

result:

wrong answer Integer 0 violates the range [1, 2] (test case 4)