Submission #91939

#TimeUsernameProblemLanguageResultExecution timeMemory
91939luckyboytrapezoid (balkan11_trapezoid)C++14
52 / 100
93 ms6720 KiB
/**Lucky Boy**/ #include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (a); i >= (b); --i) #define pb push_back #define mp make_pair #define F first #define S second #define maxc 1000000007 #define maxn 100005 #define maxm 1000006 #define pii pair <int,int> #define Task "" template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;} template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);} template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');} template <typename T> inline void writeln(T x){write(x);putchar('\n');} using namespace std; const int mod = 30013; int n,t[maxn << 1],cnt[maxn],cur,dp[maxn],add[maxn]; struct point { int x,y,type; }a[maxn << 1]; vector <int> rr; bool comp(point x,point y) { if (x.x != y.x) return x.x < y.x; return x.type < y.type; } void Update_max(int x,int val) { while (x <= 2 * n) { t[x] = max(t[x],val); x += x & -x; } } void Update_add(int x,int val) { while (x <= n) { cnt[x] += val; cnt[x] %= mod; x += x & -x; } } int Get_max(int x) { int res = 0; while (x) { res = max(res,t[x]); x -= x & -x; } return res; } int Get_cnt(int x) { int res = 0; while (x > 0) { res += cnt[x]; res %= mod; x -= x & -x; } return res; } int main() { ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL); //freopen(Task".inp", "r",stdin); //freopen(Task".out", "w",stdout); read(n); FOR(i,1,n) { int x,y,u,v; read(x),read(y),read(u),read(v); rr.pb(u); rr.pb(v); a[++cur] = {x,u,-i}; a[++cur] = {y,v,i}; } sort(rr.begin(),rr.end()); rr.resize(unique(rr.begin(),rr.end()) - rr.begin()); sort(a+1,a+cur+1,comp); FOR(i,1,cur) if (a[i].type < 0) { int pos = lower_bound(rr.begin(),rr.end(),a[i].y) - rr.begin(); dp[-a[i].type] = Get_max(pos) + 1; if (dp[-a[i].type] == 1) add[-a[i].type] = 1; else add[-a[i].type] = Get_cnt(dp[-a[i].type] - 1) - Get_cnt(dp[-a[i].type] - 2); } else { int pos = upper_bound(rr.begin(),rr.end(),a[i].y) - rr.begin(); Update_max(pos,dp[a[i].type]); Update_add(dp[a[i].type],add[a[i].type]); } int ans = Get_max(2*n); cout << ans << ' '; cout << (Get_cnt(ans) - Get_cnt(ans-1))%mod; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...