Submission #89918

# Submission time Handle Problem Language Result Execution time Memory
89918 2018-12-19T06:08:21 Z psmao Sunčanje (COCI18_suncanje) C++14
0 / 130
1834 ms 192256 KB
#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

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 time Memory Grader output
1 Incorrect 180 ms 165752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 167384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 444 ms 169712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 543 ms 171936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 798 ms 174624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 921 ms 177360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 742 ms 177360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 946 ms 178300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1324 ms 184628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1834 ms 192256 KB Output isn't correct
2 Halted 0 ms 0 KB -