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];
bitset<N> vis;
void dfs2(int x,int p, bool t, bool b){
vis[x] = 1;
if(b){
if(t){
col[0][x] = ++c[0];
col[1][x] = col[1][p];
}else{
col[0][x] = col[0][p];
col[1][x] = ++c[1];
}
}
for(auto u: g[x]){
if(u ==p)continue;
if(!vis[u])dfs2(u, x, t ^ 1, 1);
}
}
void dfs1(int x){
vis[x] = 1;
for(auto u: g[x]){
if(!vis[u])dfs1(u);
}
}
signed main(){ios::sync_with_stdio(false);cin.tie(0);
int n, m;
cin>>n>>m;
for(int i = 0;i < m;i++){
int u, v;
cin>>u>>v;
g[u].push_back(v);
g[v].push_back(u);
}
for(int i = 0;i < n;i++){
vis &= 1;
vis[i] = 1;
dfs1(g[i][0]);
if(vis.count() == n){
vis &= 0;
col[0][i] = col[0][g[i][i]] = col[1][i] = col[1][g[i][i]] = 0;
vis[i] = 1;
dfs2(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;
}
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:70:18: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
70 | if(vis.count() == n){
| ~~~~~~~~~~~~^~~~
# | 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... |