# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
513800 |
2022-01-17T16:03:04 Z |
wildturtle |
NLO (COCI18_nlo) |
C++14 |
|
3000 ms |
2512 KB |
#include<bits/stdc++.h>
#define ll long long
#define f first
#define sc second
#define pb push_back
using namespace std;
int a,n,m,k,le,ri,sz,cur;
ll ans;
int A[105],B[105],C[105];
int tree[500005],tree1[500005];
void update(int node,int le,int ri,int start,int end,int val) {
if(tree1[node]!=0) {
if(tree1[node]==2) tree[node]=0;
else tree[node]=ri-le+1;
if(le!=ri) {
tree1[2*node]=tree1[node];
tree1[2*node+1]=tree1[node];
}
tree1[node]=0;
}
if(end<le || ri<start) return;
if(start<=le && ri<=end) {
if(val==2) tree[node]=0;
else tree[node]=ri-le+1;
if(le!=ri) {
tree1[2*node]=val;
tree1[2*node+1]=val;
}
return;
}
update(2*node,le,(le+ri)/2,start,end,val);
update(2*node+1,(le+ri)/2+1,ri,start,end,val);
tree[node]=tree[2*node]+tree[2*node+1];
}
int getSum(int node,int le,int ri,int start,int end) {
if(tree1[node]!=0) {
if(tree1[node]==2) tree[node]=0;
else tree[node]=ri-le+1;
if(le!=ri) {
tree1[2*node]=tree1[node];
tree1[2*node+1]=tree1[node];
}
tree1[node]=0;
}
if(end<le || ri<start) return 0;
if(start<=le && ri<=end) {
return tree[node];
}
return getSum(2*node,le,(le+ri)/2,start,end)+getSum(2*node+1,(le+ri)/2+1,ri,start,end);
}
int main() {
std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
scanf("%d%d%d", &n, &m, &k);
for(int i=1;i<=k;i++) {
scanf("%d%d%d", &A[i], &B[i], &C[i]);
}
for(int i=1;i<=n;i++) {
a=0;
for(int j=k;j>=1;j--) {
if(abs(i-A[j])>C[j]) continue;
a=1;
sz=(C[j]*C[j])-(abs(i-A[j])*abs(i-A[j]));
sz=sqrtl(sz);
le=B[j]-sz;
ri=B[j]+sz;
sz=(ri-le+1);
cur=sz-getSum(1,1,m,le,ri);
ans+=(k-j)*cur;
update(1,1,m,le,ri,1);
}
cur=m-getSum(1,1,m,1,m);
ans+=k*cur;
if(i!=n && a!=0) update(1,1,m,1,m,2);
}
printf("%lld\n", ans);
}
Compilation message
nlo.cpp: In function 'int main()':
nlo.cpp:53:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
53 | scanf("%d%d%d", &n, &m, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
nlo.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
55 | scanf("%d%d%d", &A[i], &B[i], &C[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
332 KB |
Output is correct |
2 |
Correct |
26 ms |
332 KB |
Output is correct |
3 |
Correct |
21 ms |
332 KB |
Output is correct |
4 |
Correct |
180 ms |
540 KB |
Output is correct |
5 |
Correct |
166 ms |
1244 KB |
Output is correct |
6 |
Correct |
1322 ms |
1444 KB |
Output is correct |
7 |
Correct |
529 ms |
2264 KB |
Output is correct |
8 |
Correct |
2734 ms |
2512 KB |
Output is correct |
9 |
Correct |
1100 ms |
2360 KB |
Output is correct |
10 |
Execution timed out |
3072 ms |
2400 KB |
Time limit exceeded |