#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
ll n, m, k;
map <ll, vector <ll> > c[100005];
void processcircle(ll x, ll y, ll r, ll val){
for(int i = max(1LL, y - r) ; i <= min(m, y + r) ; ++i){
ll koef = (ll)r * (ll)r - (ll)(i - y) * (ll)(i - y);
ll t = (ll)sqrt(koef);
c[i][max(1LL, x - t)].push_back(val);
c[i][min(n + 1, x + t + 1)].push_back(-val);
//cout << i << ' ' << t << endl;
}
//cout << endl;
//system("pause");
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
cin >> k;
for(int i = 0 ; i < k ; ++i){
ll x, y, r;
cin >> x >> y >> r;
processcircle(y, x, r, i + 1);
}
for(int i = 1 ; i <= m ; ++i){
c[i][n + 1].push_back(0);
}
ll sol = 0;
//cout << endl;
for(int i = 1 ; i <= m ; ++i){
set <ll, greater <ll> > s;
ll last = 1;
for(map <ll, vector <ll> >::iterator j = c[i].begin() ; j != c[i].end() ; ++j){
//cout << last << ' ' << j->first << ' ' << (!s.empty() ? *s.begin() : 0) << endl;
sol += (j->first - last) * (k - (!s.empty() ? *s.begin() : 0));
vector <ll> v = j->second;
for(vector <ll>::iterator w = v.begin() ; w != v.end() ; ++w){
ll o = *w;
if(o < 0){
s.erase(s.find(-o));
}
else{
s.insert(o);
}
}
last = j->first;
}
//cout << endl;
}
cout << sol << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3020 ms |
7800 KB |
Time limit exceeded |
2 |
Correct |
64 ms |
14840 KB |
Output is correct |
3 |
Incorrect |
11 ms |
7160 KB |
Output isn't correct |
4 |
Execution timed out |
3057 ms |
45788 KB |
Time limit exceeded |
5 |
Execution timed out |
3052 ms |
45304 KB |
Time limit exceeded |
6 |
Runtime error |
191 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Runtime error |
135 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Runtime error |
147 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
113 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
94 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |