235902026-01-25 22:30:27abcdAdószedőcpp17Wrong answer 3/30179ms5816 KiB
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int, int>;

int main() {
    int n,m,f;cin>>n>>m>>f;
    vector<vector<int>> adj(n+1);
    for(int i=0;i<m;i++) {
        int a,b;cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    queue<int> q;
    q.push(f);
    vector<pii> ans;
    vector<bool> vis(n+1);
    vis[f]=true;
    while(!q.empty()) {
        int v=q.front();q.pop();
        for(int to:adj[v]) {
            if(!vis[to]) {
                vis[to]=true;
                q.push(to);
                ans.push_back({v,to});
            }
        }
    }
    cout<<ans.size()<<'\n';
    for(auto [a,b]:ans)cout<<a<<' '<<b<<'\n';
}
SubtaskSumTestVerdictTimeMemory
base3/30
1Wrong answer0/01ms316 KiB
2Wrong answer0/0142ms5104 KiB
3Accepted1/11ms316 KiB
4Wrong answer0/11ms316 KiB
5Wrong answer0/12ms500 KiB
6Wrong answer0/12ms316 KiB
7Wrong answer0/11ms316 KiB
8Wrong answer0/11ms316 KiB
9Accepted2/22ms508 KiB
10Wrong answer0/22ms508 KiB
11Wrong answer0/23ms316 KiB
12Wrong answer0/212ms820 KiB
13Wrong answer0/226ms1276 KiB
14Wrong answer0/2118ms4128 KiB
15Wrong answer0/1150ms5804 KiB
16Wrong answer0/1128ms4828 KiB
17Wrong answer0/2179ms5804 KiB
18Wrong answer0/2153ms5292 KiB
19Wrong answer0/2165ms5532 KiB
20Wrong answer0/2162ms5816 KiB
21Wrong answer0/2165ms5804 KiB