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 ar array
#define int long long
#define ld long double
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
const int N = 200;
const int X = N * N;
const int K = 500;
const int MOD = 1e9 + 7;
const int LOG = 21;
const int INF = 1e17;
vector<int> g[N];
int col[2][N];
int c[2];
void dfs(int x,int p, bool t, bool b){
if(b){
if(t){
col[0][x] = !col[0][p];
col[1][x] = col[1][p];
}else{
col[0][x] = col[0][p];
col[1][x] = !col[1][p];
}
}
for(auto u: g[x]){
if(u ==p)continue;
dfs(u, x, t ^ 1, 1);
}
}
signed main(){ios::sync_with_stdio(false);cin.tie(0);
int n, m;
cin>>n>>m;
for(int i = 1;i < n;i++){
int u, v;
cin>>u>>v;
g[u].push_back(v);
g[v].push_back(u);
}
for(int i = 0;i < n;i++){
if(g[i].size() == 1){
col[0][i] = col[0][g[i][i]] = col[1][i] = col[1][g[i][i]] = 0;
dfs(g[i][0], i, 1, 0);
break;
}
}
cout<<4 * n<<endl;
for(int j = 0;j < 4 * n;j++){
for(int i = 0;i < n;i++)cout<<col[j % 2][i]<<" ";
cout<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |