# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105474 | igzi | NLO (COCI18_nlo) | C++17 | 305 ms | 13880 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace::std;
set <pair<int,int>> s[100005];
long long n,m,k,i,j,a[100005],x[100005],y[100005],r[100005],ans;
long long dodaj(int p,int l,int d){
long long ans,a,b;
ans=d-l+1;
set<pair<int,int>>::iterator it;
while(true){
it=s[p].lower_bound({l,d});
if(it==s[p].end()) break;
if((*it).second<=d) {ans-=(*it).second-(*it).first+1; s[p].erase(it);}
else break;
}
it=s[p].lower_bound({l,d});
a=l;
b=d;
if(it!=s[p].end() && d+1>=(*it).first){
b=(*it).second;
ans-=d+1-(*it).first;
s[p].erase(it);
}
it=s[p].lower_bound({l,d});
if(it!=s[p].begin()){
it--;
if((*it).second+1>=l){
a=(*it).first;
ans-=(*it).second+1-l;
s[p].erase(it);
}
}
s[p].insert({a,b});
return ans;
}
int main(){
std::ios_base::sync_with_stdio(0);
cin>>n>>m>>k;
for(i=0;i<k;i++){
cin>>x[i]>>y[i]>>r[i];
}
ans=n*m*k;
for(i=k-1;i>=0;i--){
a[i]=0;
for(j=y[i]-r[i];j<=y[i]+r[i];j++){
long long d;
d=sqrt(r[i]*r[i]-(j-y[i])*(j-y[i]));
if(d*d>r[i]*r[i]-(j-y[i])*(j-y[i])) d--;
a[i]+=dodaj(j,x[i]-d,x[i]+d);
}
ans-=(i+1)*a[i];
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |