Submission #92541

# Submission time Handle Problem Language Result Execution time Memory
92541 2019-01-03T11:26:26 Z Shtef NLO (COCI18_nlo) C++14
77 / 110
304 ms 66560 KB
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <set>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
#define x first
#define y second
#define mp make_pair

ll n, m, k;
vector <pll> 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].push_back(mp(max(1LL, x - koef), val));
		c[i].push_back(mp(min(n + 1, x + koef + 1), -val));
	}
}

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;
	sort(c[i].begin(), c[i].end());
	for(int j = 0 ; j < c[i].size() ; ){
		ll t = c[i][j].x;
		sol += (t - last) * (k - (!s.empty() ? *s.begin() : 0LL));
		while(j < c[i].size() && c[i][j].x == t){
			ll o = c[i][j].y;
			if(o < 0){
				s.erase(s.find(-o));
			}
			else{
				s.insert(o);
			}
			j++;
		}
		last = t;
	}
	sol += (n + 1 - last) * k;
}
cout << sol << endl;

return 0;
}

Compilation message

nlo.cpp: In function 'int main()':
nlo.cpp:47:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j = 0 ; j < c[i].size() ; ){
                  ~~^~~~~~~~~~~~~
nlo.cpp:50:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(j < c[i].size() && c[i][j].x == t){
         ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3192 KB Output is correct
2 Correct 16 ms 4984 KB Output is correct
3 Correct 9 ms 4472 KB Output is correct
4 Correct 58 ms 15096 KB Output is correct
5 Correct 44 ms 14456 KB Output is correct
6 Runtime error 179 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Correct 138 ms 36188 KB Output is correct
8 Runtime error 188 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Correct 304 ms 65236 KB Output is correct
10 Runtime error 208 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)