Submission #92537

# Submission time Handle Problem Language Result Execution time Memory
92537 2019-01-03T11:13:25 Z Shtef NLO (COCI18_nlo) C++14
44 / 110
409 ms 66560 KB
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;

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 = (r - i + y) * (r + i - y);
		ld t = sqrt(koef);
		koef = (ll)t;
		c[i][max(1LL, x - koef)].push_back(val);
		c[i][min(n + 1, x + koef + 1)].push_back(-val);
	}
}

bool cmp(ll x, ll y){
	return x > y;
}

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(x, y, r, i + 1);
}
ll sol = 0;
for(int i = 1 ; i <= m ; ++i){
	ll last = 1;
	set <ll, greater <ll> > s;
	for(map <ll, vector <ll> >::iterator j = c[i].begin() ; j != c[i].end() ; ++j){
		ll t = j->first;
		sol += (t - last) * (k - (!s.empty() ? *s.begin() : 0LL));
		vector <ll> o = j->second;
		for(vector <ll>::iterator v = o.begin() ; v != o.end() ; ++v){
			ll u = *v;
			if(u < 0){
				s.erase(s.find(-u));
			}
			else{
				s.insert(u);
			}
		}
		last = t;
	}
	sol += (n + 1 - last) * k;
}
cout << sol << endl;

return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 7800 KB Output is correct
2 Correct 72 ms 14840 KB Output is correct
3 Correct 29 ms 14200 KB Output is correct
4 Runtime error 409 ms 65800 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
5 Correct 153 ms 62576 KB Output is correct
6 Runtime error 142 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 134 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 135 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 124 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 106 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)