QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#216127 | #6634. Central Subset | siddharthjoshi026 | WA | 1ms | 3464kb | C++20 | 1.3kb | 2023-10-15 15:59:59 | 2023-10-15 15:59:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
int main(){
long long zz;
cin>>zz;
while(zz--){
long long n,m;
cin>>n>>m;
vector<long long> adj[n+1];
vector<bool> visited(n+1,0);
vector<long long> depth(n+1,-1);
set<long long> stt;
long long bor;
for(long long i=0;i<=n;i++){
if(i*i>=n){
bor=i;
break;
}
}
for(long long i=0;i<m;i++){
long long x,y;
cin>>x>>y;
x--;y--;
adj[x].push_back(y);
adj[y].push_back(x);
}
queue<long long> q;
for(int i=0;i<100;i++){
int y=rand()%n;
q.push(y);
depth[y]=y;
stt.insert(y);
while(!q.empty()){
long long store=-1;
while(!q.empty()){
long long v=q.front();
q.pop();
visited[v]=1;
if(depth[v]==bor){
store=v;
depth[v]=0;
break;
}
for(auto x:adj[v]){
if(!visited[x]){
depth[x]=1+depth[v];
q.push(x);
}
}
}
while(!q.empty()){
q.pop();
}
if(store==-1){
for(long long i=0;i<n;i++){
if(!visited[i]){
q.push(i);
depth[i]=0;
stt.insert(i);
break;
}
}
}
else{
q.push(store);
stt.insert(store);
}
}
if(stt.size()<=bor){
cout<<stt.size()<<'\n';
for(auto x: stt){
cout<<1+x<<' ';
}
cout<<'\n';
break;}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3464kb
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 4 1 5
result:
wrong answer Condition failed: "getMaxBfsDist(n, subset) <= csqrtn" (test case 1)