답안 #91939

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91939 2018-12-31T15:04:43 Z luckyboy 사다리꼴 (balkan11_trapezoid) C++14
52 / 100
93 ms 6720 KB
/**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;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Partially correct 2 ms 376 KB Partially correct
4 Correct 2 ms 504 KB Output is correct
5 Partially correct 3 ms 504 KB Partially correct
6 Partially correct 4 ms 632 KB Partially correct
7 Partially correct 5 ms 760 KB Partially correct
8 Partially correct 5 ms 760 KB Partially correct
9 Partially correct 11 ms 1272 KB Partially correct
10 Partially correct 16 ms 1912 KB Partially correct
11 Partially correct 21 ms 2296 KB Partially correct
12 Partially correct 46 ms 3828 KB Partially correct
13 Partially correct 52 ms 4548 KB Partially correct
14 Partially correct 64 ms 5360 KB Partially correct
15 Partially correct 75 ms 5616 KB Partially correct
16 Partially correct 77 ms 5844 KB Partially correct
17 Partially correct 78 ms 6000 KB Partially correct
18 Correct 71 ms 6288 KB Output is correct
19 Partially correct 80 ms 6508 KB Partially correct
20 Partially correct 93 ms 6720 KB Partially correct