Submission #69074220


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;


ll d[1111][1111];
void init(ll n,ll m) {
  rep(i,n+1)rep(j,m) d[i][j+1]+=d[i][j];
  rep(j,m+1)rep(i,n) d[i+1][j]+=d[i][j];
}
ll calc(ll x1,ll y1,ll x2,ll y2) {return d[x2][y2]-d[x1][y2]-d[x2][y1]+d[x1][y1];}



void Init() {}
void Main() {
  ll n,T;
  cin >> n >> T;
  string s[n];
  rep(i,n) R s[i];
  rep(i,n-1) {
    rep(j,n-1) {
      if(s[i][j]=='.'&&s[i][j+1]=='.'&&s[i+1][j]=='.'&&s[i+1][j+1]=='.') {
        d[i+2][j+2]++;
      }
    }
  }
  init(n,n);
  while(T--) {
    ll x1,y1,x2,y2;
    cin >> x1 >> x2 >> y1 >> y2;
    //x1--,y1--;
    pr(calc(x1,y1,x2,y2));
  }
}

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 A - 2x2 Erasing
User kzyKT
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1638 Byte
Status AC
Exec Time 46 ms
Memory 7744 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 28
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3524 KiB
00_sample_01.txt AC 1 ms 3412 KiB
01_handmade_00.txt AC 30 ms 3460 KiB
01_handmade_01.txt AC 37 ms 7672 KiB
01_handmade_02.txt AC 1 ms 3392 KiB
01_handmade_03.txt AC 44 ms 7644 KiB
01_handmade_04.txt AC 39 ms 7640 KiB
02_random_00.txt AC 43 ms 5964 KiB
02_random_01.txt AC 39 ms 4352 KiB
02_random_02.txt AC 45 ms 7276 KiB
02_random_03.txt AC 36 ms 3872 KiB
02_random_04.txt AC 36 ms 3624 KiB
02_random_05.txt AC 46 ms 7744 KiB
02_random_06.txt AC 46 ms 7704 KiB
02_random_07.txt AC 46 ms 7712 KiB
02_random_08.txt AC 46 ms 7596 KiB
02_random_09.txt AC 45 ms 7644 KiB
02_random_10.txt AC 40 ms 7672 KiB
02_random_11.txt AC 40 ms 7608 KiB
02_random_12.txt AC 40 ms 7644 KiB
02_random_13.txt AC 40 ms 7680 KiB
02_random_14.txt AC 40 ms 7692 KiB
02_random_15.txt AC 40 ms 7620 KiB
02_random_16.txt AC 40 ms 7648 KiB
02_random_17.txt AC 40 ms 7652 KiB
02_random_18.txt AC 40 ms 7640 KiB
02_random_19.txt AC 40 ms 7668 KiB
02_random_20.txt AC 42 ms 7668 KiB