QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226339 | #6642. (1, 2) Nim | xuxubaobao | WA | 0ms | 9100kb | C++17 | 1.6kb | 2023-10-25 20:30:18 | 2023-10-25 20:30:18 |
Judging History
answer
//It's MyGO!!!
//All OK
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(0);cout << fixed << setprecision(6)
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define LNF (1ll << 60)
#define ll long long
#define ull unsighed long long
// #define int long long
// #define mod 998244353
#define mod 1000000007
using namespace std;
const int N = 2e5 + 10;
vector<int> g[N];
int dis[N];
vector<int> ans;
int sz;
int dfs(int u, int fa){
// cout << u << ' ' << fa << ' ' << dis[u] << ' ' << dis[fa] << endl;
dis[u] = dis[fa] + 1;
int maxn = 0;
for(auto v : g[u]){
if(v != fa && !dis[v]){
maxn = max(maxn, dfs(v, u) + 1);
}
}
// cout << u << ' ' << maxn << ' ' << sz << endl;
if(maxn == sz && u != 1){
ans.push_back(u);
return 0;
}
return maxn;
}
void solve(){
int n, m; cin >> n >> m;
sz = ceil(sqrt(n));
// cout << sz << endl;
memset(dis, 0, sizeof dis);
for(int i = 1; i <= n; i ++)
g[i].clear();
ans.clear();
for(int i = 1; i <= m; i ++){
int u, v; cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
ans.push_back(1);
dfs(1, 0);
cout << ans.size() << endl;
for(auto i : ans)
cout << i << ' ';
cout << '\n';
// cout << '\n';
}
signed main(){
ios;
// init();
int _ = 1;
cin >> _;
for(int __ = 1; __ <= _; __ ++){
// cout << "Case #" << __ << ": ";
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 9100kb
input:
3 2 1 2 1 5 4 1 7 2 9
output:
1 1 1 1 1 1
result:
wrong answer 1st lines differ - expected: 'Grundy', found: '1'