Rotate the image by 90 degrees (clockwise). Given input matrix = [ [1,2,3,4], [5,6,7,8], [9,10,11,12]] ], rotate the input matrix in-place such that it becomes: [ [9,5,1], [10,6,2], [11,7,3] [12,8,4] ] [[1,2,3,4], [[9,10,11,12], …
题意 题目链接 Sol 一个不太容易发现但是又很显然的性质: 如果有两个相邻的红格子,那么第一问答案为0, 第二问可以推 否则第一问答案为偶数格子上的白格子数,第二问答案为偶数格子上的红格子数 #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 #d…
Code: #include<bits/stdc++.h> using namespace std; #define setIO(s) freopen(s".in","r",stdin) #define maxn 200000 #define inf 10000000000000 #define get(x) (ch[f[x]][1]==x) #define ll long long int root,cc,kk; int h[maxn],ch[maxn…