Submission #1300197


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) { int ret = 1; while (b > 0) { if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1; } return ret; }
int modinv(int a) { return modpow(a, mod - 2); }
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/



int N, M;
vector<pair<int, int>> rule[303];
int dp[303][303][303];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        int L, R, X; cin >> L >> R >> X;
        rule[R].push_back({ L, X });
    }

    int ans = 0;
    dp[0][0][0] = 1;
    rep(r, 0, N + 1) rep(g, 0, N + 1) rep(b, 0, N + 1) {
        int ma = max(r, max(g, b));
        int mi = min(r, min(g, b));
        int md = r + g + b - ma - mi;

        for (auto p : rule[ma]) {
            int L = p.first, X = p.second;

            if (X == 1) {
                if (L <= md) dp[r][g][b] = 0;
            } else if (X == 2) {
                if (md < L) dp[r][g][b] = 0;
                else if (L <= mi) dp[r][g][b] = 0;
            } else if (X == 3) {
                if (mi < L) dp[r][g][b] = 0;
            }
        }

        if (ma == N) ans = add(ans, dp[r][g][b]);

        dp[ma + 1][g][b] = add(dp[ma + 1][g][b], dp[r][g][b]);
        dp[r][ma + 1][b] = add(dp[r][ma + 1][b], dp[r][g][b]);
        dp[r][g][ma + 1] = add(dp[r][g][ma + 1], dp[r][g][b]);
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task E - RGB Sequence
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 800
Code Size 2588 Byte
Status AC
Exec Time 357 ms
Memory 108800 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 800 / 800
Status
AC × 4
AC × 47
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 384 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 2 ms 2432 KB
1_00.txt AC 315 ms 108800 KB
1_01.txt AC 295 ms 108800 KB
1_02.txt AC 291 ms 108800 KB
1_03.txt AC 324 ms 108800 KB
1_04.txt AC 329 ms 108800 KB
1_05.txt AC 294 ms 108800 KB
1_06.txt AC 289 ms 108800 KB
1_07.txt AC 296 ms 108800 KB
1_08.txt AC 326 ms 108800 KB
1_09.txt AC 304 ms 108800 KB
1_10.txt AC 277 ms 108800 KB
1_11.txt AC 293 ms 108800 KB
1_12.txt AC 329 ms 104704 KB
1_13.txt AC 308 ms 108800 KB
1_14.txt AC 287 ms 108800 KB
1_15.txt AC 333 ms 108800 KB
1_16.txt AC 324 ms 108800 KB
1_17.txt AC 301 ms 108800 KB
1_18.txt AC 279 ms 108800 KB
1_19.txt AC 282 ms 108800 KB
1_20.txt AC 326 ms 108800 KB
1_21.txt AC 302 ms 108800 KB
1_22.txt AC 285 ms 108800 KB
1_23.txt AC 330 ms 108800 KB
1_24.txt AC 357 ms 108800 KB
1_25.txt AC 301 ms 108800 KB
1_26.txt AC 266 ms 106752 KB
1_27.txt AC 280 ms 108800 KB
1_28.txt AC 323 ms 108800 KB
1_29.txt AC 293 ms 108800 KB
1_30.txt AC 276 ms 108800 KB
1_31.txt AC 309 ms 106752 KB
1_32.txt AC 338 ms 108800 KB
1_33.txt AC 292 ms 108800 KB
1_34.txt AC 272 ms 106752 KB
1_35.txt AC 281 ms 108800 KB
1_36.txt AC 279 ms 104704 KB
1_37.txt AC 284 ms 108800 KB
1_38.txt AC 285 ms 108800 KB
1_39.txt AC 291 ms 108800 KB
1_40.txt AC 282 ms 108800 KB
1_41.txt AC 289 ms 108800 KB
1_42.txt AC 297 ms 108800 KB