Submission #894330

#TimeUsernameProblemLanguageResultExecution timeMemory
894330vjudge1NLO (COCI18_nlo)C++11
44 / 110
3069 ms2496 KiB
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 1e5 + 10;
const ll mod = 1e9 + 7;

ll um(ll a, ll b){
	return ((1LL * a * b) % mod + mod) % mod;
}
ll subr(ll a, ll b){
	return ((1LL * a - b) % mod + mod) % mod;
}
ll add(ll a, ll b){
	return ((1LL * a + b) % mod + mod) % mod;
}
ll binpow(ll x, ll step){
	ll res = 1LL;
	while(step){
		if(step & 1) res = um(res, x);
		x = um(x, x);
		step /= 2;
	}
	return res;
}
/*
	Восемь восемьсот пять пять пять
	три пять три пять
	Проще кому то позвонить
	чем у кого-то деньги занимать
*/
ll x[N], y[N], r[N];
int main() {
	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	int n, m, q, ans = 0;
  	cin >> n >> m >> q;
  	for(int i = 0; i < q; i++){
  		cin >> x[i] >> y[i] >> r[i];
  	}
  	for(ll i = 1; i <= n; i++){
  		for(ll j = 1; j <= m; j++){
  			bool was = false;
  			for(ll k = q - 1; k >= 0; k--){
  				ll s1 = abs(i - x[k]) * abs(i - x[k]);
  				ll s2 = abs(j - y[k]) * abs(j - y[k]);
  				if(s1 + s2 <= r[k] * r[k]){
  					ans += (q - k - 1);
  					was = true;
  					break;
  				}
  			}
  			if(!was) ans += q;
  		}
  	}
  	cout << ans;
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...