結果
| 問題 | No.2574 Defect-free Rectangles |
| コンテスト | |
| ユーザー |
👑 potato167
|
| 提出日時 | 2023-12-06 00:20:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 229 ms / 2,000 ms |
| コード長 | 867 bytes |
| 記録 | |
| コンパイル時間 | 2,202 ms |
| コンパイル使用メモリ | 204,792 KB |
| 最終ジャッジ日時 | 2025-02-18 07:59:54 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
int main() {
ll H,W,N;
cin>>H>>W>>N;
vector p(H,vector<bool>(W));
rep(i,0,N){
int a,b;cin>>a>>b;
a--,b--;
p[a][b]=1;
}
ll ans=0;
vector<ll> q(W+2);
rep(i,0,H){
rep(j,0,W){
q[j+1]++;
if(p[i][j]) q[j+1]=0;
}
stack<int> st;
st.push(0);
rep(j,1,W+2){
while((int)st.size()!=1){
int a=st.top();
if(q[a]<q[j]){
break;
}
st.pop();
ll wid=j-st.top()-1;
ll hig=q[a]-max(q[st.top()],q[j]);
ans+=hig*(wid*(wid+1))/2;
}
st.push(j);
}
}
cout<<ans<<"\n";
}
potato167