# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
894354 |
2023-12-28T07:07:33 Z |
vjudge1 |
NLO (COCI18_nlo) |
C++17 |
|
119 ms |
65536 KB |
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define getlast(s) (*s.rbegin())
#define debg cout << "OK\n"
const ld PI = 3.1415926535;
const int N = 2e5 + 2;
const int M = 7e6 + 1;
int mod = 1e9+7;
const int infi = INT_MAX;
const ll infl = LLONG_MAX;
const int P = 31;
int mult(int a, int b) {
return a * 1LL * b % mod;
}
int sum(int a, int b) {
a %= mod;
if (a + b < 0)
return a + b + mod;
if (a + b >= mod)
return a + b - mod;
return a + b;
}
ll binpow(ll a, ll n) {
if (n == 0)
return 1;
if (n % 2 == 1) {
return binpow(a, n - 1) * a % mod;
} else {
ll b = binpow(a, n / 2);
return b * b % mod;
}
}
struct kazakhskayazadachapizdec{
struct node{
int op, sm, lch, rch, l, r;
node(){
l = -1;
r = -1;
sm = 0;
op = 0;
lch = -1;
rch = -1;
}
node(int _l, int _r){
l = _l;
r = _r;
sm = 0;
op = 0;
lch = -1;
rch = -1;
}
};
vector<node> t;
int cur = 0;
kazakhskayazadachapizdec(){
t.pb(node(1, 1e5));
}
void push(int v){
if(t[v].l == t[v].r)
return;
int m = (t[v].l + t[v].r) / 2;
if(t[v].lch == -1){
t[v].lch = ++cur;
t.pb(node(t[v].l, m));
}
if(t[v].rch == -1){
t[v].rch = ++cur;
t.pb(node(m + 1, t[v].r));
}
if(t[v].op == 0)
return;
if(t[v].op == -1){
t[t[v].lch].op = -1;
t[t[v].rch].op = -1;
t[t[v].lch].sm = 0;
t[t[v].rch].sm = 0;
}else{
if(t[t[v].lch].op == -1){
push(t[v].lch);
}
t[t[v].lch].op += t[v].op;
t[t[v].lch].sm += (m - t[v].l + 1) * t[v].op;
if(t[t[v].rch].op == -1){
push(t[v].rch);
}
t[t[v].rch].op += t[v].op;
t[t[v].rch].sm += (t[v].r - m) * t[v].op;
}
t[v].op = 0;
}
int get(int v, int l, int r){
push(v);
if(t[v].l > r || t[v].r < l)
return 0;
if(t[v].l >= l && t[v].r <= r){
return t[v].sm;
}
return get(t[v].lch, l, r) + get(t[v].rch, l, r);
}
void reset(int v, int l, int r){
push(v);
if(t[v].l > r || t[v].r < l){
return;
}
if(t[v].l >= l && t[v].r <= r){
t[v].op = -1;
t[v].sm = 0;
return;
}
reset(t[v].lch, l, r);
reset(t[v].rch, l, r);
t[v].sm = t[t[v].lch].sm + t[t[v].rch].sm;
}
void add(){
push(0);
t[0].op = 1;
t[0].sm += (t[0].r - t[0].l + 1);
}
};
void solve(){
int n, m;
cin >> n >> m;
kazakhskayazadachapizdec ts[m + 1];
int q;
cin >> q;
while(q--){
int xi, yi, ri;
cin >> yi >> xi >> ri;
for(int j = 1; j <= m; j++)
ts[j].add();
for(int x = max(xi - ri, 1LL); x <= min(xi + ri, m); x++){
ld b = -2 * yi, c = yi * yi - ri * ri + (xi - x) * (xi - x);
int y1 = max((int)ceil((-b - sqrtl(b * b - 4 * c)) / 2), 1LL);
int y2 = min((int)floor((-b + sqrtl(b * b - 4 * c)) / 2), n);
ts[x].reset(0, y1, y2);
}
}
int ans = 0;
for(int j = 1; j <= m; j++){
ans += ts[j].get(0, 1, n);
}
cout << ans << '\n';
}
signed main() {
mispertion;
int t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
38228 KB |
Output is correct |
2 |
Runtime error |
119 ms |
65536 KB |
Execution killed with signal 9 |
3 |
Runtime error |
55 ms |
65536 KB |
Execution killed with signal 9 |
4 |
Runtime error |
44 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Runtime error |
48 ms |
65536 KB |
Execution killed with signal 9 |
6 |
Runtime error |
46 ms |
65536 KB |
Execution killed with signal 9 |
7 |
Runtime error |
50 ms |
65536 KB |
Execution killed with signal 9 |
8 |
Runtime error |
48 ms |
65536 KB |
Execution killed with signal 9 |
9 |
Runtime error |
46 ms |
65536 KB |
Execution killed with signal 9 |
10 |
Runtime error |
47 ms |
65536 KB |
Execution killed with signal 9 |