結果

問題 No.1997 X Lighting
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-08-09 14:18:59
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 1,107 bytes
コンパイル時間 5,702 ms
コンパイル使用メモリ 317,352 KB
実行使用メモリ 11,324 KB
最終ジャッジ日時 2024-04-27 09:12:45
合計ジャッジ時間 10,777 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 5 ms
6,944 KB
testcase_06 AC 32 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 4 ms
6,944 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 54 ms
6,940 KB
testcase_14 AC 176 ms
11,324 KB
testcase_15 AC 42 ms
6,944 KB
testcase_16 AC 54 ms
6,944 KB
testcase_17 AC 141 ms
9,952 KB
testcase_18 AC 78 ms
7,124 KB
testcase_19 AC 188 ms
10,900 KB
testcase_20 AC 220 ms
11,200 KB
testcase_21 AC 209 ms
11,296 KB
testcase_22 AC 217 ms
10,992 KB
testcase_23 AC 107 ms
7,428 KB
testcase_24 AC 6 ms
6,944 KB
testcase_25 AC 198 ms
11,072 KB
testcase_26 AC 170 ms
9,928 KB
testcase_27 AC 168 ms
10,064 KB
testcase_28 AC 51 ms
6,944 KB
testcase_29 AC 49 ms
6,944 KB
testcase_30 AC 216 ms
10,820 KB
testcase_31 AC 119 ms
8,400 KB
testcase_32 AC 30 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<ll,ll>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  ll n,m;cin>>n>>m;
  vc<pp>va,vb;
  rep(i,m){
    ll x,y;cin>>x>>y;
    if((x+y)&1)va.pb({x,y});
    else vb.pb({x,y});
  }
  ll res=0;
  auto f=[&](vc<pp>v)->void{
    set<ll>s,sx;
    for(auto [x,y]:v){
      ll t=x+y-1;
      s.insert(t);
      sx.insert(x-(y-1));
    }
    for(ll t:s){
      res+=t;
      if(t>n)res-=2*(t-n);
    }
    vc<ll>sv(1,0);
    for(ll t:s)sv.pb(t);
    for(ll t:sx){
      if(t<1)res+=n-(1-t);
      else res+=n+1-t;
     // 1<= (t+at)/2<=n  at>=t  (at-t)/2<=n-1    at<= 2n-2+t
      ll l=max(2-t,t),r=min(2*n-2+t,2*n-t);
      ll it=upper_bound(all(sv),r)-lower_bound(all(sv),l);
      res-=it;
    }
  };
  f(va); f(vb);
  cout<<res;
}
     
      
0