Submission #69097833


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ex exit(0)
#define ln cout<<'\n'
#define ll long long
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.12f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Init() {}
void Main() {
  ll n,m;
  cin >> n >> m;
  string s[n];
  rep(i,n) R s[i];
  ll f=1;
  rep(i,n) {
    rep(j,m) {
      if(s[i][j]=='#') {
        ll c=0;
        rep(k,4) {
          ll x=i+dx[k],y=j+dy[k];
          if(check(n,m,x,y)&&s[x][y]=='#') c++;
        }
        if(c!=2&&c!=4) f=0;
      }
    }
  }
  if(f) pr("Yes");
  else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Init();ll T=1;if(0)R T;while(T--)Main();return 0;}

Submission Info

Submission Time
Task B - Looped Rope
User kzyKT
Language C++ 20 (gcc 12.2)
Score 200
Code Size 1412 Byte
Status AC
Exec Time 1 ms
Memory 3604 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 02_handmade_14.txt, 02_handmade_15.txt, 02_handmade_16.txt, 02_handmade_17.txt, 02_handmade_18.txt, 02_handmade_19.txt, 02_handmade_20.txt, 02_handmade_21.txt, 02_handmade_22.txt, 02_handmade_23.txt, 02_handmade_24.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3472 KiB
00_sample_01.txt AC 1 ms 3524 KiB
00_sample_02.txt AC 1 ms 3456 KiB
00_sample_03.txt AC 1 ms 3324 KiB
01_random_04.txt AC 1 ms 3428 KiB
01_random_05.txt AC 1 ms 3472 KiB
01_random_06.txt AC 1 ms 3504 KiB
01_random_07.txt AC 1 ms 3516 KiB
01_random_08.txt AC 1 ms 3476 KiB
01_random_09.txt AC 1 ms 3520 KiB
01_random_10.txt AC 1 ms 3472 KiB
01_random_11.txt AC 1 ms 3472 KiB
01_random_12.txt AC 1 ms 3476 KiB
01_random_13.txt AC 1 ms 3460 KiB
02_handmade_14.txt AC 1 ms 3428 KiB
02_handmade_15.txt AC 1 ms 3416 KiB
02_handmade_16.txt AC 1 ms 3376 KiB
02_handmade_17.txt AC 1 ms 3384 KiB
02_handmade_18.txt AC 1 ms 3452 KiB
02_handmade_19.txt AC 1 ms 3392 KiB
02_handmade_20.txt AC 1 ms 3424 KiB
02_handmade_21.txt AC 1 ms 3508 KiB
02_handmade_22.txt AC 1 ms 3460 KiB
02_handmade_23.txt AC 1 ms 3324 KiB
02_handmade_24.txt AC 1 ms 3604 KiB