# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
894374 |
2023-12-28T07:29:58 Z |
vjudge1 |
NLO (COCI18_nlo) |
C++17 |
|
3000 ms |
14372 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;
int q;
cin >> q;
pair<pii, int> qs[q];
for(int i = 0; i < q; i++){
int xi, yi, ri;
cin >> yi >> xi >> ri;
qs[i] = {{yi, xi}, ri};
}
int ans = 0;
for(int x = 1; x <= m; x++){
for(int i = 0; i < q; i++){
ts.add();
int xi = qs[i].F.F, yi = qs[i].F.S, ri = qs[i].S;
if(abs(x - xi) <= ri){
ld b = -2 * yi, c = yi * yi - ri * ri + (xi - x) * (xi - x);
if(b * b - 4 * c < 0)
continue;
int y1 = max((int)(ceil((-b - sqrtl(b * b - 4 * c)) / 2.0)), 1LL);
int y2 = min((int)(floor((-b + sqrtl(b * b - 4 * c)) / 2.0)), n);
ts.reset(0, y1, y2);
}
}
ans += ts.get(0, 1, n);
ts.reset(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 |
Incorrect |
11 ms |
604 KB |
Output isn't correct |
2 |
Correct |
40 ms |
604 KB |
Output is correct |
3 |
Incorrect |
10 ms |
600 KB |
Output isn't correct |
4 |
Incorrect |
181 ms |
1216 KB |
Output isn't correct |
5 |
Incorrect |
133 ms |
2000 KB |
Output isn't correct |
6 |
Incorrect |
1709 ms |
8136 KB |
Output isn't correct |
7 |
Incorrect |
773 ms |
7616 KB |
Output isn't correct |
8 |
Execution timed out |
3065 ms |
14372 KB |
Time limit exceeded |
9 |
Incorrect |
1813 ms |
13748 KB |
Output isn't correct |
10 |
Execution timed out |
3046 ms |
12992 KB |
Time limit exceeded |