# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
546926 | jeroenodb | NLO (COCI18_nlo) | C++14 | 1488 ms | 62164 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 1e5+1, oo = 1e9;
int main() {
int n,m,k; cin >> n >> m >> k;
vector<map<int,int>> mp(n+1);
for(int i=1;i<=n;++i) {
mp[i] = {{1,k},{m+1,0}};
}
while(k--) {
int x,y,r; cin >> x >> y >> r;
for(int i=max(x-r,1);i<=min(m,x+r);++i) {
int dif = (x-i);
int delta = int(sqrt(ll(r)*r-ll(dif)*dif));
int lo = max(1,y-delta), hi = min(m,y+delta)+1;
// range set
auto& s = mp[i];
auto it = s.upper_bound(lo);
int last= prev(it)->second;
while(it->first < hi) {
last = it->second;
it = s.erase(it);
}
if(it->first!=hi) s[hi]=last;
s[lo]=k;
}
}
ll ans=0;
for(auto& s : mp) {
int lastx=0,last=0;
for(auto [x,h] : s) {
ans+=ll(x-lastx)*last;
lastx=x,last=h;
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |