QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#139605 | #6634. Central Subset | FzArK | WA | 14ms | 8552kb | C++17 | 1.8kb | 2023-08-14 02:48:58 | 2023-08-14 02:48:59 |
Judging History
answer
#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define clr(x) vector<int>().swap(x);
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define endl '\n'
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define random mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
const ll INF=1e18;
const ll MN=-2e9;
const ll MX=2e5+9;
const ll MXX=1e9;
const ll SQ=4e2;
const ll MOD=998244353;
const ll PP=1e6+3;
const ld PI=3.141592653589793;
const ld eps=1e-11;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;
int n, m, q, vis[MX];
vector<int> ans, adj[MX];
void init() {
q = 0;
ans.clear();
for (int i=1; i<=n; i++) {
vis[i] = 0;
adj[i].clear();
}
}
void go(int u, int d) {
if (vis[u]) return;
if (!d) ans.pb(u);
vis[u] = 1;
d++;
d %= q;
for (auto v:adj[u]) go(v, d);
}
void solve() {
cin >> n >> m;
while (m--) {
int u, v;
cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
while (q*q < n) q++;
q++;
go(1, 0);
cout << sz(ans) << endl;
for (auto x:ans) cout << x << " "; cout << endl;
init();
}
int main() {
FAST;
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 8552kb
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: 14ms
memory: 8304kb
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 10 9 8 7 1 1 4 1 7 13 19 3 1 6 7 3 1 10 6 4 1 13 12 11 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 11 13 9 3 1 6 12 3 1 11 10 1 1 2 1 5 3 1 6...
result:
wrong answer Integer 5 violates the range [1, 4] (test case 9)