QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#147417 | #6634. Central Subset | qzez# | WA | 26ms | 8596kb | C++14 | 1.3kb | 2023-08-23 07:28:42 | 2023-08-25 01:29:27 |
Judging History
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);
if(ans.empty()) ans.emplace_back(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';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 8596kb
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: 26ms
memory: 8488kb
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 1 1 1 1 2 6 3 1 1 1 4 2 10 3 1 1 3 15 10 5 1 3 1 2 1 5 1 1 3 11 7 3 1 1 1 1 1 2 1 1 1 2 1 3 1 4 2 5 1 1 1 3 11 7 3 1 1 2 5 1 1 1 1 1 4 16 11 6 1 1 2 1 4 2 7 4 1 1 1 3 1 2 1 3 3 7 6 1 1 1 2 8 4 1 1 1 3 1 2 1 1 2 6 2 1 3 1 3 2 5 1 1 1 ...
result:
wrong answer Condition failed: "getMaxBfsDist(n, subset) <= csqrtn" (test case 1107)