Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
using namespace std; typedef long long ll; const int maxn = 3e5 + 10; const ll INF = 3e16 + 10; struct node { int y, x1, x2; bool up; node () {} node(int _y, int _x1, int _x2, bool _up) { y = _y; x1 = _x1; x2 = _x2; up = _up; } bool operator < (const node &tmp) const { return y < tmp.y; } }; int main() { ios_base::sync_with_stdio(false); int L, W; cin >> L >> W; int months; cin >> months; int n; cin >> n; vector
> buildings(n); vector
v; for(int i = 0; i < n; i++) { cin >> buildings[i].first >> buildings[i].second; v.push_back(node(max(1, buildings[i].second - months), max(1, buildings[i].first - months), min(L, buildings[i].first + months), true)); v.push_back(node(min(W, buildings[i].second + months), max(1, buildings[i].first - months), min(L, buildings[i].first + months), false)); } sort(v.begin(), v.end()); stack
st; ll result = 0; for(int x = 1; x <= L; x++) { int st_max = 0; for(int i = 0; i < (int) v.size(); i++) { if(v[i].x1 <= x and x <= v[i].x2) { if(v[i].up) { st.push(v[i].y); } else { if(st.size() == 1) { result += v[i].y - max(st.top(), st_max) + 1; st_max = v[i].y + 1; } st.pop(); } } } } cout << result << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)