結果
| 問題 | No.2574 Defect-free Rectangles | 
| コンテスト | |
| ユーザー |  Magentor | 
| 提出日時 | 2023-11-13 17:26:00 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,680 bytes | 
| コンパイル時間 | 3,916 ms | 
| コンパイル使用メモリ | 267,148 KB | 
| 実行使用メモリ | 44,032 KB | 
| 最終ジャッジ日時 | 2024-09-26 03:21:50 | 
| 合計ジャッジ時間 | 8,843 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 9 TLE * 3 -- * 5 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
#define rep(i, n) for (int i = 0; i < (long long)(n); i++)
#define rep2(i, m ,n) for (int i = (m); i < (long long)(n); i++)
#define REP(i, n) for (long long i = 1; i < (long long)(n); i++)
typedef long long ll;
#define updiv(N,X) (N + X - 1) / X
#define l(n) n.begin(),n.end()
#define YesNo(Q) Q==1?cout<<"Yes":cout<<"No"
using P = pair<int, int>;
const int MOD = 998244353LL;
ll solve(vector<ll> &w){
set<int> st;int n = w.size();
vector<pair<int,int>> v(n);
rep(i,n){v[i] = pair(w[i],i);}
sort(l(v));
st.insert(-1);
st.insert(n);
ll ans = 0;
rep(i,n){
  auto t = st.lower_bound(v[i].second);
  auto k = t;k--;
  ans += (ll)(v[i].second-(int)(*k)) * ((ll)(*t)-v[i].second) * v[i].first;
  st.insert(v[i].second);
}
return ans;
}
int main(){
  ll h,w,n;cin>>h>>w>>n;
  vector<vector<int>> v(h,vector<int>(w,0));
  rep(i,n){
  int a,b;cin>>a>>b;a--;b--;
  v[a][b] = 1;
  }
//  otp(v);
  //vector<vector<ll>> t(h,vector<ll>(w,0));
  rep(i,h){
    ll now = 0;
    rep(j,w){now++;if(v[i][w-j-1]==1){now = 0;}v[i][w-j-1] = now;}
  }
 // otp(v);
  ll ans = 0;
  rep(i,w){vector<ll> w(h);
  
    rep(j,h){w[j] = v[j][i];}
   // rep(j,h){cout << w[j] << " ";}cout<<endl;
    ans += solve(w);
   // cout << solve(w).val() << endl;
  }
 // vector<ll> y={2,1,3,4,5};
  //cout << solve(y) << endl;
  //cout << solveg(y) << endl;
  cout << ans << endl;
}
            
            
            
        