Submission #894330

# Submission time Handle Problem Language Result Execution time Memory
894330 2023-12-28T05:52:51 Z vjudge1 NLO (COCI18_nlo) C++11
44 / 110
3000 ms 2496 KB
#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 time Memory Grader output
1 Correct 38 ms 2396 KB Output is correct
2 Correct 32 ms 2396 KB Output is correct
3 Correct 950 ms 2496 KB Output is correct
4 Correct 2160 ms 2488 KB Output is correct
5 Execution timed out 3031 ms 2392 KB Time limit exceeded
6 Execution timed out 3055 ms 2396 KB Time limit exceeded
7 Execution timed out 3069 ms 2396 KB Time limit exceeded
8 Execution timed out 3055 ms 2396 KB Time limit exceeded
9 Execution timed out 3053 ms 2396 KB Time limit exceeded
10 Execution timed out 3066 ms 2396 KB Time limit exceeded