meaning of the title
Sol
This question is a test of reading comprehension.
If you can read it, it's not difficult to find out that this is how many points with a degree of (0\) are counted.
Judge after the shrinkage point
Of course, there is an exception \(1-> 3, 2-> 3), that is, there is an isolated point, can be judged.
When judging, three conditions should be satisfied: the size of the connecting block is\(2\), the degree of entry is 0, and the degree of entry of all points is greater than\(2\)
In addition, the title does not say whether there is a heavy side, I have not judged, but it is better to judge.
/* */ #include<bits/stdc++.h> #define Pair pair<int, int> #define MP(x, y) make_pair(x, y) #define fi first #define se second //#define int long long #define LL long long #define rg register #define pt(x) printf("%d ", x); #define Fin(x) {freopen(#x".in","r",stdin);} #define Fout(x) {freopen(#x".out","w",stdout);} using namespace std; const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7, B = 1; const double eps = 1e-9; inline int read() { char c = getchar(); int x = 0, f = 1; while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();} while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } int N, a[MAXN], b[MAXN], f[MAXN]; void solve(int val) { f[N] = val; for(int i = N - 1; i >= 1; i--) { bool flag = 0; for(int j = 0; j <= 3; j++) { int nx = f[i + 1]; f[i] = j; if((a[i] == (f[i] | f[i + 1])) && (b[i] == (f[i] & f[i + 1]))) {flag = 1; break;} } if(!flag) return ; } puts("YES"); for(int i = 1; i <= N; i++) printf("%d ", f[i]); exit(0); } main() { //Fin(a); N = read(); for(int i = 1; i <= N - 1; i++) a[i] = read(); for(int i = 1; i <= N - 1; i++) b[i] = read(); solve(0); solve(1); solve(2); solve(3); puts("NO"); return 0; } /* */