# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
799306 | elotelo966 | Naboj (COCI22_naboj) | C++17 | 98 ms | 21440 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 1000000005
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mid (start+end)/2
#define mod 1000000007
vector <int> v[200005];
int re[200005];
vector <pair<int,int>> cev;
inline void dfs(int node,int ata,int renk){
for(int i=0;i<v[node].size();i++){
int go=v[node][i];
if(go==ata || re[go]!=-1)continue;
re[go]=renk^1;
//cout<<node<<" "<<renk<<'\n';
cev.push_back({go,renk^1});
dfs(go,ata,renk^1);
}
}
int32_t main(){
faster
int n,m;cin>>n>>m;
memset(re,-1,sizeof(re));
for(int i=0;i<m;i++){
int a,b;cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
re[1]=0;
cev.push_back({1,0});
dfs(1,-1,0);
cout<<cev.size()<<'\n';
for(int i=0;i<cev.size();i++){
cout<<cev[i].first<<" "<<cev[i].second<<'\n';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |