답안 #633663

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
633663 2022-08-23T02:21:55 Z iee NLO (COCI18_nlo) C++17
110 / 110
779 ms 336 KB
// iee
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using db = double;
using ld = long double;
#define py puts("YES")
#define pn puts("NO")
#define pf puts("-1")
#define hh puts("")
#define fi first
#define se second
#define mkp make_pair
#define re =RD()
#define rd RD()
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define ep emplace
#define ci const int
#define vi vector<int>
#define fn for(int i=1;i<=n;++i)
#define rept(t) for(int I=t;I-->0;)
#define rep(stO,a,b) for(int stO=(a);stO<=(b);stO++)
#define Rep(stO,a,b) for(int stO=(a);stO<(b);stO++)
#define per(Orz,a,b) for(int Orz=(a);Orz>=(b);Orz--)
#define ina int n,a[N];
#define rna n=RD();fn a[i]=RD();
using namespace std;
void big(int &x,int y){if(y>x)x=y;}void sml(int &x,int y){if(y<x)x=y;}
int qpow(int a, int b, int p) { int res = 1 % p; while (b) { if (b % 2) res = 1ll * res * a % p; a = 1ll * a * a % p; b /= 2; } return res; }
int RD() { int x = 0, f = 1, ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + (ch - '0'); ch = getchar(); } return x * f; }
//ci p = 998244353 1000000007; int fac[N], inv[N], ifac[N]; int binom(int x, int y, int MOD = p) { if (x < y) return 0; return 1ll * fac[x] * ifac[y] % p * ifac[x - y] % p; } void init(int LIM = N - 1, int MOD = p) { fac[0] = ifac[0] = inv[1] = 1; rep(i, 1, LIM) fac[i] = 1ll * fac[i - 1] * i % MOD; rep(i, 2, LIM) inv[i] = 1ll * (MOD - MOD / i) * inv[MOD % i] % MOD; rep(i, 1, LIM) ifac[i] = 1ll * ifac[i - 1] * inv[i] % MOD; }
void work(int);

signed main() { int CASINPUT = 1;
  string op = R"(
                 )";if (op.size() == 19) cin >> CASINPUT; rep(CUR, 1, CASINPUT) work(CUR); }
ci N = 1e5 + 5, K = 105;
int n, m, k;
int xx[N], yy[N], rr[N], ans;
void solve(int X){
 vector<tuple<int,int,int>>hp;
 rep(i,1,k) {
  int x=xx[i], y=yy[i], r=rr[i];
  if(abs(x - X)>r) continue;
  int rad = (int)floor(sqrt(r*r - (X-x)*(X-x)));
  int yl = max(1ll,y - rad);
  int yr = min(m,y + rad);
  hp.eb(yl,1,i);hp.eb(yr + 1,-1,i);
 }
 sort(all(hp));
 set<int>q;
 int lst = 0;
 for(auto vv:hp){
  int y,c,i;tie(y,c,i) = vv;
  if(!q.empty()) ans -= (y-lst) * (*q.rbegin());
  lst = y;
  if(c == 1)q.ep(i);
  else q.erase(i);
 }
}
void work(int CASE) {
 n re, m re, k re;
 rep(i,1,k) xx[i] re, yy[i] re, rr[i] re;
 ans += n*m*k;
 rep(i,1,n) solve(i);
 cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 12 ms 336 KB Output is correct
3 Correct 8 ms 320 KB Output is correct
4 Correct 49 ms 300 KB Output is correct
5 Correct 29 ms 320 KB Output is correct
6 Correct 304 ms 316 KB Output is correct
7 Correct 87 ms 212 KB Output is correct
8 Correct 573 ms 312 KB Output is correct
9 Correct 178 ms 320 KB Output is correct
10 Correct 779 ms 320 KB Output is correct