Submission #71668745


Source Code Expand

#if !__INCLUDE_LEVEL__
#include __FILE__

void solve() {
  int N,M;
  cin>>N>>M;
  set<pii> mp;
  int cnt=0;
  rep(i,M){
    int r,c;
    cin>>r>>c;
    r--,c--;
    bool flag=true;
    for(auto [dx,dy]:dir){
      int nx=dx+r,ny=dy+c;
      if((!grid_inside(N,N,nx,ny))||mp.count({nx,ny}))flag=false;
    }
    if(flag){
      cnt++;
       for(auto [dx,dy]:dir){
      int nx=dx+r,ny=dy+c;
      mp.insert({nx,ny});
    }
    }
  }
  cout<<cnt<<el;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)solve();
}

#else
#include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint=modint998244353;

  
// 関数テンプレート
template<typename T> bool chmax(T &m, const T q) {
    if (m < q) {m = q; return true;} else return false; }

template<typename T> bool chmin(T &m,const T q){
    if(m>q){m=q;return true;}else return false;
}
template<typename T>
bool grid_inside(const T h, const T w, const T &m, const T &n) {
    return (m >= 0 && m < h && n >= 0 && n < w);
}
// ループマクロ
#define rep(i,r) for(int i=0;(r)>i;i++)
#define REP(i,l,r) for(int i=(l);i<(r);i++)
#define rrep(i,N) for(int i=(N)-1;i>=0;i--)
#define RREP(i,r,N) for(int i=(N)-1;i>=r;i--)

// コンテナショートカット
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define el '\n'
#define spa " "
#define pb push_back

// YES/NO 出力
#define Yes cout<<"Yes"<<el
#define No cout<<"No"<<el
#define YES cout<<"YES"<<el
#define NO cout<<"NO"<<el
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

// 型エイリアス
using ll=long long;
using ull=unsigned long long;
using pqgi=priority_queue<int, vector<int>, greater<int>>;
using pqgl=priority_queue<long long, vector<long long>, greater<long long>>;
using pqgpl=priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>>;
using pqgptpl=priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>>;
using pqi=priority_queue<int>;
using pii=pair<int, int>;
using tpi=tuple<int,int,int>;
using tpl=tuple<ll,ll,ll>;
using pll=pair<long long, long long>;
using vs=vector<string>;
using vi=vector<int>;
using vb=vector<bool>;
using vl=vector<long long>;
using vc=vector<char>;
using vvi=vector<vector<int>>;
using vvl=vector<vector<long long>>;
using vvc=vector<vector<char>>;
using vvb=vector<vector<bool>>;
using vvs=vector<vector<string>>;
using vpii=vector<pii>;
using vpll=vector<pll>;
using vvpii=vector<vector<pii>>;
using vvpll=vector<vector<pll>>;
using vtiii=vector<tuple<int, int, int>>;

// 定数
const long long INF=1e18;
const int mod=1e9+7;
//const int mod=998244353;
const int MAX=1e5+10;
const int MIN=-1e9;
const vpii dir={{1,0},{1,1},{0,1},{0,0}};
#endif


Submission Info

Submission Time
Task C - 2x2 Placing
User yasaikeikaku
Language C++23 (GCC 15.2.0)
Score 300
Code Size 3103 Byte
Status AC
Exec Time 385 ms
Memory 41140 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 36
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_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, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3568 KiB
00_sample_01.txt AC 1 ms 3568 KiB
00_sample_02.txt AC 1 ms 3604 KiB
01_random_00.txt AC 8 ms 3456 KiB
01_random_01.txt AC 14 ms 3544 KiB
01_random_02.txt AC 19 ms 3636 KiB
01_random_03.txt AC 67 ms 3732 KiB
01_random_04.txt AC 64 ms 11184 KiB
01_random_05.txt AC 95 ms 4532 KiB
01_random_06.txt AC 191 ms 24752 KiB
01_random_07.txt AC 371 ms 39444 KiB
01_random_08.txt AC 208 ms 22804 KiB
01_random_09.txt AC 385 ms 40980 KiB
01_random_10.txt AC 49 ms 11412 KiB
01_random_11.txt AC 328 ms 41072 KiB
02_random2_00.txt AC 326 ms 41140 KiB
02_random2_01.txt AC 324 ms 40944 KiB
02_random2_02.txt AC 324 ms 40656 KiB
02_random2_03.txt AC 322 ms 40244 KiB
02_random2_04.txt AC 320 ms 39780 KiB
02_random2_05.txt AC 315 ms 39548 KiB
02_random2_06.txt AC 301 ms 38768 KiB
02_random2_07.txt AC 299 ms 37908 KiB
02_random2_08.txt AC 293 ms 36916 KiB
02_random2_09.txt AC 286 ms 35316 KiB
02_random2_10.txt AC 272 ms 33000 KiB
02_random2_11.txt AC 262 ms 30384 KiB
02_random2_12.txt AC 228 ms 25808 KiB
02_random2_13.txt AC 200 ms 20500 KiB
02_random2_14.txt AC 141 ms 12900 KiB
02_random2_15.txt AC 65 ms 3892 KiB
03_handmade_00.txt AC 14 ms 3604 KiB
03_handmade_01.txt AC 129 ms 22420 KiB
03_handmade_02.txt AC 152 ms 22324 KiB
03_handmade_03.txt AC 140 ms 22448 KiB
03_handmade_04.txt AC 111 ms 16028 KiB