QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#579768 | #6634. Central Subset | Milan | WA | 19ms | 3816kb | C++23 | 1.4kb | 2024-09-21 17:47:19 | 2024-09-21 17:47:19 |
Judging History
answer
#include <bits/stdc++.h>
#define MULTI int _; cin >> _; while(_--)
#define fi first
#define se second
#define pb(a) push_back(a)
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, n, m) for(int i = n; i <= m; i++)
#define repsv(i, n, m) for(int i = n; i >= m; i--)
#define vsz(a) (int)(a.size())
#define mp(a, b) make_pair(a, b)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
#ifdef LOCAL
#include "debugs.hpp"
#else
#define dbg(...) 0
#endif
vector<vi> to;
void rmv(int i, int rn, vb &ex){
if(rn < 0 || (ex[i] == false)) return;
rn--;
ex[i] = false;
for(int j : to[i])
rmv(j, rn, ex);
}
void solve(){
int n, m;
cin >> n >> m;
vb ex(n, true);
to = vector<vi>(n);
rep(i, m){
int u, v;
cin >> u >> v;
u--, v--;
to[u].pb(v);
to[v].pb(u);
}
int rn = ceil(sqrt((double)n));
vi res;
rep(i, n){
if(ex[i]){
rmv(i, rn, ex);
res.pb(i);
}
}
cout << vsz(res) << '\n';
for(int i : res)
cout << i+1 << ' ';
cout << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
MULTI
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3500kb
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:
2 1 4 1 1
result:
ok correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 19ms
memory: 3816kb
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 1 6 11 1 1 3 1 6 10 1 1 1 1 3 1 5 9 1 1 3 1 6 12 5 1 7 8 9 10 1 1 4 1 7 13 19 3 1 6 7 3 1 6 10 4 1 11 12 13 1 1 3 1 6 11 1 1 1 1 2 1 9 1 1 2 1 4 2 1 6 3 1 6 12 3 1 13 14 1 1 3 1 6 11 1 1 3 1 6 13 1 1 1 1 4 1 7 13 19 4 1 9 11 13 3 1 6 12 3 1 10 11 1 1 2 1 5 3 1 6...
result:
wrong answer Integer 5 violates the range [1, 4] (test case 9)