답안 #90042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90042 2018-12-19T22:41:26 Z psmao Sunčanje (COCI18_suncanje) C++14
0 / 130
228 ms 263168 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> Set1, Set2;}t[maxn*30];
 
void upd(int l, int r, int L, int R, int x, int k)
{
	if(x < 0) // erase operation
	{
		if(t[k].Set2.find(-x) != t[k].Set2.end()) t[k].Set2.erase(-x);
	}
	else
	{
		t[k].Set2.insert(x);
		set<int>:: iterator it = t[k].Set1.lower_bound(x);
		if(!SZ(t[k].Set1) || it == t[k].Set1.begin()) ;
		else
		{
			int v = -1;
			while(1)
			{
				-- it;
				if(v != -1) t[k].Set1.erase(v);
				v = (*it); Ans[v] = false;
				if(it == t[k].Set1.begin()) break;
			}
			if(v != -1) t[k].Set1.erase(v);
		}
		it = t[k].Set1.upper_bound(x);
		if(it != t[k].Set1.end()) Ans[x] = false;
	}
	if(l <= L && R <= r)
	{
		if(x < 0)
		{
			if(t[k].Set1.find(-x) != t[k].Set1.end()) t[k].Set1.erase(-x);
		}
		else
		{
			t[k].Set1.insert(x);
			set<int>:: iterator it = t[k].Set2.lower_bound(x);
			if(!SZ(t[k].Set2) || it == t[k].Set2.begin()) ;
			else
			{
				int v = -1;
				while(1)
				{
					-- it;
					if(v != -1) t[k].Set2.erase(v);
					v = (*it); Ans[v] = false;
					if(it == t[k].Set2.begin()) break;
				}
				if(v != -1) t[k].Set2.erase(v);
			}
			it = t[k].Set2.upper_bound(x);
			if(it != t[k].Set2.end()) 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:112:4: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  sf("%d",&n);
    ^
suncanje.cpp:116: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);
     ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 228 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 224 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 206 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 184 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 183 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 220 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 210 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 203 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 224 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 214 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -