# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
508704 | lukameladze | NLO (COCI18_nlo) | C++14 | 630 ms | 328 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include <bits/stdc++.h>
#define f first
#define int long long
#define s second
#define pb push_back
#define pii pair <int, int>
using namespace std;
const int N = 105;
int t,n,k,x[N],y[N],r[N],sum,kat,ans,rem,mx,sz,m,ans1;
multiset <int> ms;
vector < pii > v;
char ch;
main() {
std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
cin>>k;
for (int i = 1; i <= k; i++) {
cin>>x[i]>>y[i]>>r[i];
}
for (int i = 1; i <= n; i++) {
v.clear(); ms.clear();
for (int j = k; j >= 1; j--) {
if (abs(x[j] - i) > r[j]) continue;
kat = abs(x[j] - i);
rem = (r[j]*r[j])-(kat*kat);
rem = sqrtl(rem);
//cout<<y[j]-rem<<" "<<y[j] + rem<<" " <<j<<endl;
v.pb({y[j] - rem, j});
v.pb({y[j] + rem + 1, -j});
}
ans1 = m * k;
v.pb({m+1,0});sort(v.begin(),v.end());
for (int j = 0; j < (int)v.size() - 1; j++) {
if (v[j].s >= 0) {
ms.insert(v[j].s);
} else {
//cout<<ms.count(-v[j].s)<<"S"<<endl;
ms.erase(ms.find(-v[j].s));
}
if (ms.size()) {
mx = *(--ms.end());
rem = mx;
if (v[j + 1].f >= v[j].f) {
sz = (v[j + 1].f - v[j].f);
ans1 -= rem * sz;
// cout<<i<<" "<<rem<<" "<<v[j].f<<" "<<v[j + 1].f<<endl;
}
}
}
ans += ans1;
}
cout<<ans<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |