Codeforces Round #777 (Div. 2) B. Madoka and the Elegant Gift

 

 【题目大意】:

  如果任意两个最大矩形不相交则输出YES,否则输出NO。

【思路】:

  数据范围比较小,100*100.所以可以暴力遍历。

  找到最大矩形相交   ---------   不能出现【俄罗斯方块中的L形】 , 例如一个点右边下边都是1 但是右下角是0 就不行。 所以是任意点的右,下,右下中不能有三个是1,一个是0。这样就会形成两个矩形。

【代码】:

复制代码
 1 #include <bits/stdc++.h>
 2 #include <iostream>
 3 #include <cstdio>
 4 #include <cstring>
 5 #include <algorithm>
 6 #include <string>
 7 #include <vector>
 8 #include <stack>
 9 #include <bitset>
10 #include <cstdlib>
11 #include <cmath>
12 #include <set>
13 
14 #define ms(a, b) memset(a,b,sizeof(a))
15 #define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
16 #define ll long long
17 #define ull unsigned long long
18 #define rep(i, a, b)  for(ll i=a;i<=b;i++)
19 #define lep(i, a, b)  for(ll i=a;i>=b;i--)
20 #define endl '\n'
21 #define pii pair<int, int>
22 #define pll pair<ll, ll>
23 #define vi  vector<ll>
24 #define vpi vector<pii>
25 #define vpl vector<pll>
26 #define mi  map<ll,ll>
27 #define all(a)  (a).begin(),(a).end()
28 #define gcd __gcd
29 #define pb push_back
30 #define mp make_pair
31 #define lb lower_bound
32 #define ub upper_bound
33 
34 #define ff first
35 #define ss second
36 #define test4(x, y, z, a) cout<<"x is "<<x<<"        y is "<<y<<"        z is "<<z<<"        a is "<<a<<endl;
37 #define test3(x, y, z) cout<<"x is "<<x<<"        y is "<<y<<"        z is "<<z<<endl;
38 #define test2(x, y) cout<<"x is "<<x<<"        y is "<<y<<endl;
39 #define test1(x) cout<<"x is "<<x<<endl;
40 using namespace std;
41 const int N =150;
42 const int maxx = 0x3f3f3f;
43 const int mod = 1e9 + 7;
44 const int minn = -0x3f3f3f;
45 const int M = 2 * N;
46 ll T, n, m;
47 char s[N][M];
48 int  a[N][M];
49 int flag1[N][M],flag2[N][M];
50 void solve() {
51     cin>>n>>m;
52     rep(i,1,n){
53         rep(j,1,m){
54             cin>>s[i][j];
55             a[i][j]= s[i][j]-'0';
56         }
57     }
58     rep(i,1,n-1){
59         rep(j,1,m-1){
60             if ( a[i][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1] == 3 ) {cout<<"NO"<<endl;return ;}
61         }
62     }
63     cout<<"YES"<<endl;return ;
64 }
65 
66 int main() {
67     fast;
68     cin >> T;
69     while (T--) {
70         solve();
71     }
72     return 0;
73 }
View Code
复制代码

 

posted @   Pan_c  阅读(83)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示