Submission #106147

# Submission time Handle Problem Language Result Execution time Memory
106147 2019-04-16T20:37:56 Z Kewo trapezoid (balkan11_trapezoid) C++17
0 / 100
5 ms 512 KB
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);
const int mod = (int)(30013);

int n, ans, tot;
ii tree[N << 2], dp[N];
set<int> s;
unordered_map<int, int> mp;
vector<ii> ev;

struct trap {
	int a, b, c, d;
	void read() {
		cin >> a >> b >> c >> d;
	}
	void compress() {
		a = mp[a];
		b = mp[b];
		c = mp[c];
		d = mp[d];
	}
}ar[N];

ii merge(ii x, ii y) {
	ii re;
	if(x.fi == y.fi)
		return {x.fi, (x.se + y.se) % mod};
	else
		return max(x, y);
}

void upd(int ind, int x, int y, int a, ii val) {
	if(a < x || y < a)
		return;
	if(x == y) {
		tree[ind] = val;
		return;
	}
	upd(left, x, mid, a, val);
	upd(right, mid + 1, y, a, val);
	tree[ind] = merge(tree[left], tree[right]);
}

ii get(int ind, int x, int y, int a, int b) {
	if(y < a || b < x)
		return {-1, 0};
	if(a <= x && y <= b)
		return tree[ind];
	return merge(get(left, x, mid, a, b), get(right, mid + 1, y, a, b));
}

int main() {
	fast_io();
	freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= n; i++) {
		ar[i].read();
		s.insert(ar[i].a);
		s.insert(ar[i].b);
		s.insert(ar[i].c);
		s.insert(ar[i].d);
	}
	int t = 0;
	for(auto i : s)
		mp[i] = ++t;

	for(int i = 1; i <= n; i++)
		ar[i].compress();

	for(int i = 1; i <= n; i++) {
		ev.pb({i, 0});
		ev.pb({i, 1});
	}

	sort(ev.begin(), ev.end(), [&] (ii x, ii y) {
		int cmpx, cmpy;
		if(x.se == 0)
			cmpx = ar[x.fi].c;
		else
			cmpx = ar[x.fi].d;
		if(y.se == 0)
			cmpy = ar[y.fi].c;
		else
			cmpy = ar[y.fi].d;
		return cmpx < cmpy;
	});

	upd(1, 0, t, 0, {0, 1});

	for(auto i : ev) {
		int ind = i.fi;
		if(i.se == 0) {
			ii g = get(1, 0, t, 0, ar[ind].a - 1);
			dp[ind] = {g.fi + 1, g.se};
		}
		else
			upd(1, 0, t, ar[ind].b, dp[ind]);
		ans = max(ans, dp[ind].fi);
	}
	for(int i = 1; i <= n; i++)
		if(dp[i].fi == ans) {
			tot += dp[i].se;
			if(tot > mod)
				tot %= mod;
		}
	cout << ans << spc << tot;
}

Compilation message

trapezoid.cpp: In function 'int main()':
trapezoid.cpp:76:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("inp.in", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Incorrect 3 ms 512 KB Output isn't correct
3 Incorrect 4 ms 384 KB Output isn't correct
4 Incorrect 3 ms 512 KB Output isn't correct
5 Incorrect 4 ms 384 KB Output isn't correct
6 Incorrect 4 ms 384 KB Output isn't correct
7 Incorrect 4 ms 512 KB Output isn't correct
8 Incorrect 5 ms 384 KB Output isn't correct
9 Incorrect 4 ms 384 KB Output isn't correct
10 Incorrect 5 ms 384 KB Output isn't correct
11 Incorrect 4 ms 384 KB Output isn't correct
12 Incorrect 3 ms 384 KB Output isn't correct
13 Incorrect 5 ms 384 KB Output isn't correct
14 Incorrect 4 ms 384 KB Output isn't correct
15 Incorrect 5 ms 512 KB Output isn't correct
16 Incorrect 3 ms 384 KB Output isn't correct
17 Incorrect 4 ms 384 KB Output isn't correct
18 Incorrect 3 ms 384 KB Output isn't correct
19 Incorrect 3 ms 384 KB Output isn't correct
20 Incorrect 3 ms 384 KB Output isn't correct