#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:336777216")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define tl fi.fi
#define tr fi.se
#define dl se.fi
#define dr se.se
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)
#define __TIME (1.0 * clock() / CLOCKS_PER_SEC)
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 5e5 + 5;
const int oo = 1e9, mod = 30013;
pair <ii, ii> a[N];
ii bit[N];
int n;
void update (int x, ii val) {
for (; x <= 2 * n; x += x & -x)
if (bit[x].fi < val.fi)
bit[x] = val;
else if (bit[x].fi == val.fi)
bit[x].se = (bit[x].se + val.se) % mod;
}
ii get (int x) {
ii ans = {0, 1};
for (; x > 0; x -= x & -x)
if (bit[x].fi > ans.fi)
ans = bit[x];
else if (bit[x].fi == ans.fi)
ans.se = (ans.se + bit[x].se) % mod;
return ans;
}
ii ret, res[N];
vector <int> t, d;
int g[N], u[N];
void process() {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i].tl >> a[i].tr >> a[i].dl >> a[i].dr;
t.pb(a[i].tl);
t.pb(a[i].tr);
d.pb(a[i].dl);
d.pb(a[i].dr);
}
sort(t.begin(), t.end());
sort(d.begin(), d.end());
t.erase(unique(t.begin(), t.end()), t.end());
d.erase(unique(d.begin(), d.end()), d.end());
for (int i = 1; i <= n; ++i) {
a[i].tl = lower_bound (t.begin(), t.end(), a[i].tl) - t.begin() + 1;
a[i].tr = lower_bound (t.begin(), t.end(), a[i].tr) - t.begin() + 1;
a[i].dl = lower_bound (d.begin(), d.end(), a[i].dl) - d.begin() + 1;
a[i].dr = lower_bound (d.begin(), d.end(), a[i].dr) - d.begin() + 1;
g[a[i].tl] = i;
u[a[i].tr] = i;
}
for (int i = 1; i <= 2 * n; i++) {
if (g[i]) {
int v = g[i];
ii f = get(a[v].dl);
++f.fi;
res[v] = f;
if (f.fi > ret.fi)
ret = f;
else if (f.fi == ret.fi)
ret.se = (ret.se + f.se) % mod;
}
else {
int v = u[i];
update(a[v].dr, res[v]);
}
}
cout << ret.fi << " " << ret.se;
return;
}
signed main() {
cin.tie(0)->sync_with_stdio(false);
//freopen(".inp", "r", stdin);
//freopen(".out", "w", stdout);
process();
cerr << "Time elapsed: " << __TIME << " s.\n";
return 0;
}
// dont stop
Compilation message
trapezoid.cpp:4: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
4 | #pragma comment(linker, "/stack:336777216")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
4 |
Correct |
2 ms |
8792 KB |
Output is correct |
5 |
Correct |
2 ms |
8796 KB |
Output is correct |
6 |
Correct |
3 ms |
8792 KB |
Output is correct |
7 |
Correct |
4 ms |
8948 KB |
Output is correct |
8 |
Correct |
5 ms |
9052 KB |
Output is correct |
9 |
Correct |
9 ms |
9376 KB |
Output is correct |
10 |
Correct |
17 ms |
11760 KB |
Output is correct |
11 |
Correct |
22 ms |
13792 KB |
Output is correct |
12 |
Correct |
47 ms |
19388 KB |
Output is correct |
13 |
Correct |
53 ms |
19896 KB |
Output is correct |
14 |
Correct |
65 ms |
20656 KB |
Output is correct |
15 |
Correct |
71 ms |
20912 KB |
Output is correct |
16 |
Correct |
81 ms |
21172 KB |
Output is correct |
17 |
Correct |
94 ms |
21552 KB |
Output is correct |
18 |
Correct |
78 ms |
21904 KB |
Output is correct |
19 |
Correct |
82 ms |
21740 KB |
Output is correct |
20 |
Correct |
91 ms |
22248 KB |
Output is correct |