Submission #89918

#TimeUsernameProblemLanguageResultExecution timeMemory
89918psmaoSunčanje (COCI18_suncanje)C++14
0 / 130
1834 ms192256 KiB
#include <bits/stdc++.h> using namespace std; #define fo(i,s,t) for(int i = s; i <= t; ++ i) #define fd(i,s,t) for(int i = s; i >= t; -- i) #define bf(i,s) for(int i = head[s]; i; i = e[i].next) #define mp make_pair #define fi first #define se second #define pii pair<int,int> #define pb push_back #define VI vector<int> #define sf scanf #define pf printf #define fp freopen #define SZ(x) ((int)(x).size()) #ifdef MPS #define D(x...) printf(x) #else #define D(x...) #endif typedef long long ll; typedef double db; typedef unsigned long long ull; const int inf = 1<<30; const ll INF = 1ll<<60; const db Inf = 1e20; const db eps = 1e-9; void gmax(int &a,int b){a = (a > b ? a : b);} void gmin(int &a,int b){a = (a < b ? a : b);} const int maxn = 100050; struct event{int p, y1, y2, v;}a[maxn<<1]; int n, tot, num = 1; bool Ans[maxn]; struct node{int l, r; set<int> Set;}t[maxn*30]; void upd(int l, int r, int L, int R, int x, int k) { if(x > 0) { set<int>:: iterator it = t[k].Set.upper_bound(x); if(it != t[k].Set.end()) Ans[x] = false; t[k].Set.insert(x); }else if(t[k].Set.find(-x) != t[k].Set.end()) t[k].Set.erase(-x); if(l <= L && R <= r) { if(x < 0) // erase operation { if(t[k].Set.find(-x) != t[k].Set.end()) t[k].Set.erase(-x); } else { set<int>:: iterator it = t[k].Set.lower_bound(x); while(it != t[k].Set.begin()) { int v = (*it); -- it; if(v != x) t[k].Set.erase(v); Ans[(*it)] = false; } it = t[k].Set.upper_bound(x); if(it != t[k].Set.end()) {t[k].Set.erase(x); Ans[x] = false;} } return; } int mid = (L + R) >> 1; if(r <= mid) {if(!t[k].l) t[k].l = ++num; upd(l, r, L, mid, x, t[k].l);} else if(l > mid) {if(!t[k].r) t[k].r = ++num; upd(l, r, mid+1, R, x, t[k].r);} else { if(!t[k].l) t[k].l = ++ num; upd(l, mid, L, mid, x, t[k].l); if(!t[k].r) t[k].r = ++ num; upd(mid+1, r, mid+1, R, x, t[k].r); } } bool cmp(event a, event b){return a.p != b.p ? a.p < b.p : a.v < b.v;} int main() { #ifdef MPS fp("1.in","r",stdin); fp("1.out","w",stdout); #endif sf("%d",&n); fo(i,1,n) { int x, y, l1, l2; sf("%d%d%d%d",&x,&y,&l1,&l2); a[++tot] = (struct event){x, y, y+l2-1, i}; a[++tot] = (struct event){x+l1, y, y+l2-1, -i}; } sort(a+1, a+tot+1, cmp); memset(Ans, 1, sizeof(Ans)); fo(i,1,tot) upd(a[i].y1, a[i].y2, 0, 1000000000, a[i].v, 1); fo(i,1,n) if(Ans[i]) pf("DA\n"); else pf("NE\n"); return 0; }

Compilation message (stderr)

suncanje.cpp: In function 'int main()':
suncanje.cpp:87:4: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  sf("%d",&n);
    ^
suncanje.cpp:91:5: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   sf("%d%d%d%d",&x,&y,&l1,&l2);
     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...