답안 #404845

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
404845 2021-05-15T06:52:58 Z Forested Boat (APIO16_boat) C++17
9 / 100
3 ms 1228 KB
// Template
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <tuple>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <array>
#include <cassert>
#include <cmath>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll infll = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T> 
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &element : vec) is >> element;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    for (int i = 0, vec_len = (int)vec.size(); i < vec_len; ++i) {
        os << vec[i] << (i + 1 == vec_len ? "" : " ");
    }
    return os;
}
struct IOSET {
    IOSET() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} ioset;

// Mod-Int
#include <iostream>

template <unsigned int mod>
struct ModInt {
    static_assert(mod >= 1 && mod < (1u << 31));
    
    unsigned int val;
    
    ModInt() : val(0) {}
    
    ModInt(long long x) : val(x < 0 ? x % mod + mod : (unsigned long long)x % mod) {}
    
    ModInt<mod> &operator+=(const ModInt<mod> &x) {
        val += x.val;
        if (val >= mod) val -= mod;
        return *this;
    }
    
    ModInt<mod> &operator-=(const ModInt<mod> &x) {
        if (val < x.val) val += mod;
        val -= x.val;
        return *this;
    }
    
    ModInt<mod> &operator*=(const ModInt<mod> &x) {
        unsigned long long s = (unsigned long long)val * x.val;
        val = (unsigned int)(s % mod);
        return *this;
    }
    
    ModInt<mod> operator+() const {
        return *this;
    }
    
    ModInt<mod> operator-() const {
        return ModInt<mod>(0u) - *this;
    }
    
    friend ModInt<mod> operator+(const ModInt<mod> &x, const ModInt<mod> &y) {
        return ModInt<mod>(x) += y;
    }
    
    friend ModInt<mod> operator-(const ModInt<mod> &x, const ModInt<mod> &y) {
        return ModInt<mod>(x) -= y;
    }
    
    friend ModInt<mod> operator*(const ModInt<mod> &x, const ModInt<mod> &y) {
        return ModInt<mod>(x) *= y;
    }
    
    friend std::istream &operator>>(std::istream &is, ModInt<mod> &x) {
        is >> x.val;
        // x.value %= mod;
        return is;
    }
    
    friend std::ostream &operator<<(std::ostream &os, const ModInt<mod> &x) {
        os << x.val;
        return os;
    }
    
    ModInt<mod> pow(unsigned long long x) const {
        ModInt<mod> res(1), s(*this);
        while (x) {
            if (x & 1) res *= s;
            s *= s;
            x >>= 1;
        }
        return res;
    }
    
    // --- prime number ---
    ModInt<mod> &operator/=(const ModInt<mod> &x) {
        *this *= x.pow(mod - 2);
        return *this;
    }
    
    friend ModInt<mod> operator/(const ModInt<mod> &x, const ModInt<mod> &y) {
        return ModInt<mod>(x) /= y;
    }
};

// Main
int main() {
    constexpr unsigned mod = 1000000007;
    using Mint = ModInt<mod>;
    
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    
    // subtask 1
    assert(n <= 500);
    rep(i, n) assert(a[i] == b[i]);
    
    vector<vector<Mint>> dp(n + 1, vector<Mint>(n, Mint(0)));
    rep(i, n) {
        dp[i + 1][i] += Mint(1);
        rep(j, n) {
            dp[i + 1][j] += dp[i][j];
            if (j < i && a[j] < a[i]) dp[i + 1][i] += dp[i][j];
        }
    }
    
    Mint ans(0);
    rep(i, n) ans += dp[n][i];
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1228 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 2 ms 1228 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 3 ms 1224 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 2 ms 1228 KB Output is correct
9 Correct 2 ms 1212 KB Output is correct
10 Correct 2 ms 1212 KB Output is correct
11 Correct 3 ms 1228 KB Output is correct
12 Correct 3 ms 1228 KB Output is correct
13 Correct 2 ms 1212 KB Output is correct
14 Correct 3 ms 1220 KB Output is correct
15 Correct 3 ms 1228 KB Output is correct
16 Correct 2 ms 1216 KB Output is correct
17 Correct 2 ms 1216 KB Output is correct
18 Correct 2 ms 1228 KB Output is correct
19 Correct 3 ms 1220 KB Output is correct
20 Correct 3 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1228 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 2 ms 1228 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 3 ms 1224 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 2 ms 1228 KB Output is correct
9 Correct 2 ms 1212 KB Output is correct
10 Correct 2 ms 1212 KB Output is correct
11 Correct 3 ms 1228 KB Output is correct
12 Correct 3 ms 1228 KB Output is correct
13 Correct 2 ms 1212 KB Output is correct
14 Correct 3 ms 1220 KB Output is correct
15 Correct 3 ms 1228 KB Output is correct
16 Correct 2 ms 1216 KB Output is correct
17 Correct 2 ms 1216 KB Output is correct
18 Correct 2 ms 1228 KB Output is correct
19 Correct 3 ms 1220 KB Output is correct
20 Correct 3 ms 1228 KB Output is correct
21 Runtime error 1 ms 460 KB Execution killed with signal 6
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1228 KB Output is correct
2 Correct 2 ms 1228 KB Output is correct
3 Correct 2 ms 1228 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 3 ms 1224 KB Output is correct
6 Correct 2 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 2 ms 1228 KB Output is correct
9 Correct 2 ms 1212 KB Output is correct
10 Correct 2 ms 1212 KB Output is correct
11 Correct 3 ms 1228 KB Output is correct
12 Correct 3 ms 1228 KB Output is correct
13 Correct 2 ms 1212 KB Output is correct
14 Correct 3 ms 1220 KB Output is correct
15 Correct 3 ms 1228 KB Output is correct
16 Correct 2 ms 1216 KB Output is correct
17 Correct 2 ms 1216 KB Output is correct
18 Correct 2 ms 1228 KB Output is correct
19 Correct 3 ms 1220 KB Output is correct
20 Correct 3 ms 1228 KB Output is correct
21 Runtime error 1 ms 460 KB Execution killed with signal 6
22 Halted 0 ms 0 KB -