답안 #145973

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145973 2019-08-21T13:22:34 Z ryansee Sunčanje (COCI18_suncanje) C++14
0 / 130
585 ms 262148 KB
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (100006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define MSB(bm) ((bm==0)?-1:(63-__builtin_clzll((bm))))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
// #define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
// #define degug(...) 663
#define cerr if(0)cout
#endif
#warning "// FOR has been inclusive now!!!!"
ll n; vector<ll>d,d2; ll index(ll x) { return lbd(d,x)-d.begin(); } ll index2(ll x) { return lbd(d2,x)-d2.begin(); }
struct rectangle {
	ll a,b,c,d;
} A[MAXN];
struct node {
	int s,e,m;
	ll v,add;
	node *l,*r;
	node(ll _S,ll _E){
		s=_S,e=_E,m=(s+e)>>1;
		v=0;add=0;
		l=r=0;
	}
	void cl() { if(!l)l=new node(s,m); }
	void cr() { if(!r)r=new node(m+1,e); }
	void update(ll x,ll y,ll nval) {
		if(s==x&&e==y) { add+=nval; return; }
		if(x>m)cr(), r->update(x,y,nval);
		else if(y<=m)cl(), l->update(x,y,nval);
		else cl(), cr(), l->update(x,m,nval),r->update(m+1,y,nval);
		v=(l?l->value():0)+(r?r->value():0);
	}
	ll value() { if(add==0) return v;
		v+=add;
		if(s^e){
			cl(); l->add+=add;
			cr(); r->add+=add;
		}
		add=0;
		return v;
	}
	ll rmq(ll x,ll y){ value(); 
		if(s==x&&e==y) return v;
		if(x>m) return r?r->rmq(x,y):0;
		else if(y<=m) return l?l->rmq(x,y):0;
		else return (l?l->rmq(x,m):0) + (r?r->rmq(m+1,y):0);
	}
};
struct node2d {
	int s,e,m;
	node *v;
	node2d *l,*r;
	node2d(ll _S,ll _E){
		s=_S,e=_E,m=(s+e)>>1;
		v=new node(0,siz(d2)-1);
		l=r=0;
	}
	void cl() { if(!l)l=new node2d(s,m); }
	void cr() { if(!r)r=new node2d(m+1,e); }
	void update(ll x,ll y,ll c,ll d,ll nval){
		if(s==x&&e==y) { v->update(c,d,nval); return; }
		if(x>m)cr(), r->update(x,y,c,d,nval);
		else if(y<=m)cl(), l->update(x,y,c,d,nval);
		else cl(), cr(), l->update(x,m,c,d,nval),r->update(m+1,y,c,d,nval);
	}
	ll rmq(ll x,ll y,ll c,ll d) {
		if(s==x&&e==y) return v->rmq(c,d);
		ll add=v->rmq(c,d);
		if(x>m)return (r?r->rmq(x,y,c,d):0)+add;
		else if(y<=m)return (l?l->rmq(x,y,c,d):0)+add;
		else return (l?l->rmq(x,m,c,d):0)+(r?r->rmq(m+1,y,c,d):0)+add;
	}
} *seg;

int main()
{
	FAST
	cin>>n;
	FOR(i,1,n){ cin>>A[i].a>>A[i].b>>A[i].c>>A[i].d; A[i].c=A[i].a+A[i].c-1; A[i].d=A[i].b+A[i].d-1; swap(A[i].a,A[i].b), swap(A[i].c,A[i].d); d.eb(A[i].a), d.eb(A[i].c); d2.eb(A[i].b), d2.eb(A[i].d); }
	sort(all(d)); d.resize(unique(all(d))-d.begin()); sort(all(d2)); d2.resize(unique(all(d2))-d2.begin()); vector<string>ans; seg=new node2d(0,siz(d)-1);
	DEC(i,n,1) {
		// cerr<<A[i].a<<' '<<A[i].b<<' '<<A[i].c<<' '<<A[i].d<<' '<<fen.rmq(A[i].a+1,A[i].c+1,A[i].b+1,A[i].d+1)<<'\n';
		if(seg->rmq(index(A[i].a),index(A[i].c),index2(A[i].b),index2(A[i].d))==0) ans.eb("DA\n"); else ans.eb("NE\n");
		seg->update(index(A[i].a),index(A[i].c),index2(A[i].b),index2(A[i].d),1);
	}
	reverse(all(ans));
	for(auto i:ans) cout<<i;
}

/*
5
1 1 4 2
6 1 1 1
2 2 2 3
3 4 3 2
4 0 1 2
*
3
3 3 1 1
2 2 3 3
1 1 5 5
* 
2
2 2 2 3
3 4 3 2
*/ 

Compilation message

suncanje.cpp:42:2: warning: #warning "// FOR has been inclusive now!!!!" [-Wcpp]
 #warning "// FOR has been inclusive now!!!!"
  ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 33780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 378 ms 159516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 579 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 567 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 571 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 552 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 585 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 582 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 574 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 572 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -