QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#139606 | #6634. Central Subset | FzArK | RE | 1ms | 8908kb | C++17 | 1.9kb | 2023-08-14 02:51:47 | 2023-08-14 02:51:50 |
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);
assert (sz(ans) < q);
cout << sz(ans) << endl;
for (auto x:ans) cout << x << " "; cout << endl;
init();
}
int main() {
FAST;
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
/*
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 8908kb
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
Dangerous Syscalls
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 ...