답안 #250798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250798 2020-07-19T07:43:47 Z hackermub Boat (APIO16_boat) C++17
0 / 100
2 ms 384 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(v) (int)v.size()
const int MOD = 998244353;
const int64_t INF = 1e18;

int add(int a,int b){
    return (a+b+MOD)%MOD; 
}

int mul(int a,int b){
    return (1LL*a*b)%MOD;
}

int bigmod(int b,int p){
    if(!p) return 1;
    int x = bigmod(b,p/2);
    x = mul(x,x);
    if(p%2) x = mul(x,b);
    return x;
}

int vag(int a,int b){
    return mul(a,bigmod(b,MOD-2));
}

void getseg(vector<pii> &seg,vector<int> &L,vector<int> &R){
    vector<pii> v;
    for(auto x:L) v.push_back({x,0});
    for(auto x:R) v.push_back({x,1});
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    for(int i=1;i<sz(v);i++){
        if(v[i].second == 1){
            if(v[i-1].second == 0) seg.push_back({v[i-1].fi,v[i].fi});
            else seg.push_back({v[i-1].fi+1,v[i].fi});
        }else if(v[i-1].second == 0){
            seg.push_back({v[i-1].fi,v[i].fi-1});
        }
    }
}

int32_t main(){
    ios_base::sync_with_stdio(0),cin.tie(),cout.tie();
    int n;
    cin>>n;
    vector<int> L(n+1),R(n+1);
    for(int i=1;i<=n;i++){
       cin>>L[i]>>R[i];
    }
    vector<int> dp(n+1);
    dp[0]=1;
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<i;j++){
            if(L[j]<L[i]) dp[i]=add(dp[i],dp[j]);
        }
        ans=add(ans,dp[i]);
    }
   // cout<<dp[1]<<" "<<dp[2]<<endl;
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -