# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
633273 |
2022-08-22T03:05:47 Z |
iee |
Sunčanje (COCI18_suncanje) |
C++17 |
|
1601 ms |
231956 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); }
#define x1 jioejwrojoirjw
#define x2 jrioewjrojweoirj
#define y1 fjewjriowejorje
#define y2 rweojroiwejroihjw
ci N = 1e6 + 5;
int n, x1[N], y1[N], x2[N], y2[N];
int ans[N];
int lshx[N], lshy[N], tx, ty;
int calcx(int x) { return lower_bound(lshx + 1, lshx + tx + 1, x) - lshx; }
int calcy(int y) { return lower_bound(lshy + 1, lshy + ty + 1, y) - lshy; }
set<pii> lz[N], tr[N];
bool nc(set<pii> &s, int l, int r) { //未覆盖
if (s.empty()) return 1;
auto il = s.lower_bound(mkp(l, 0));
if (il != end(s) && il->fi <= r) return 0;
if (il != begin(s) && prev(il)->se >= l) return 0;
return 1;
}
void addy(set<pii> &s, int l, int r) {
if (s.empty()) { s.ep(l, r); return; }
auto il = s.upper_bound(mkp(l, 0)), ir = s.upper_bound(mkp(r, 1e18));
if (il != begin(s)) {
--il;
if (il->se < l) ++il;
}
vector<pii> del;
while (il != ir) del.eb(*il), l = min(l, il->fi), r = max(r, il->se), il++;
for (auto it: del) s.erase(it);
s.ep(l, r);
}
bool addx(int u, int l, int r, int ql, int qr, int yl, int yr) {
bool res = nc(tr[u], yl, yr);
if (l >= ql && r <= qr) {
res &= nc(lz[u], yl, yr);
addy(lz[u], yl, yr);
addy(tr[u], yl, yr);
return res;
}
addy(lz[u], yl, yr);
int mid = l + r >> 1;
if (ql <= mid) res &= addx(u << 1, l, mid, ql, qr, yl, yr);
if (qr > mid) res &= addx(u << 1 | 1, mid + 1, r, ql, qr, yl, yr);
return res;
}
void work(int CASE) {
n re;
fn{
int x re, y re, a re, b re;
x1[i] = x;
x2[i] = x + a - 1;
y1[i] = y;
y2[i] = y + b - 1;
}
fn lshx[++tx] = x1[i], lshx[++tx] = x2[i];
fn lshy[++ty] = y1[i], lshy[++ty] = y2[i];
sort(lshx + 1, lshx + tx + 1);
sort(lshy + 1, lshy + ty + 1);
tx = unique(lshx + 1, lshx + tx + 1) - lshx - 1;
ty = unique(lshy + 1, lshy + ty + 1) - lshy - 1;
fn {
x1[i] = calcx(x1[i]);
x2[i] = calcx(x2[i]);
y1[i] = calcy(y1[i]);
y2[i] = calcy(y2[i]);
}
per(i,n,1) ans[i] = addx(1, 1, tx, x1[i], x2[i], y1[i], y2[i]);
fn if(ans[i]) puts("DA"); else puts("NE");
}
Compilation message
suncanje.cpp: In function 'bool addx(long long int, long long int, long long int, long long int, long long int, long long int, long long int)':
suncanje.cpp:82:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
82 | int mid = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
98892 KB |
Output is correct |
2 |
Correct |
86 ms |
101168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
105800 KB |
Output is correct |
2 |
Correct |
584 ms |
149996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
283 ms |
114196 KB |
Output is correct |
2 |
Correct |
737 ms |
167644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
347 ms |
123240 KB |
Output is correct |
2 |
Correct |
606 ms |
156392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
647 ms |
150264 KB |
Output is correct |
2 |
Correct |
805 ms |
169316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
621 ms |
145892 KB |
Output is correct |
2 |
Correct |
798 ms |
170268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
697 ms |
161508 KB |
Output is correct |
2 |
Correct |
768 ms |
152472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1060 ms |
195972 KB |
Output is correct |
2 |
Correct |
651 ms |
144044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1152 ms |
192872 KB |
Output is correct |
2 |
Correct |
1221 ms |
204752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1285 ms |
197984 KB |
Output is correct |
2 |
Correct |
1601 ms |
231956 KB |
Output is correct |