Submission #3429655


Source Code Expand

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll dp[301][3][300][300];
vector<P> v[300];
int main() {
	rep(j, 3) {
		dp[0][j][0][0] = 1;
	}
	int n, m; cin >> n >> m;
	rep(i, m) {
		int le, ri, x; cin >> le >> ri >> x; ri--;
		v[ri].push_back({ le,x });
	}
	rep(i, n) {
		rep(k, i + 1) {
			rep(l, i + 1) {
				rep(j, 3) {
					(dp[i + 1][j][k][l] += dp[i][j][k][l])%=mod;
				}
				(dp[i + 1][0][i][l] += dp[i][1][k][l]) %= mod;
				(dp[i + 1][0][k][i] += dp[i][2][k][l]) %= mod;
				(dp[i + 1][1][i][l] += dp[i][0][k][l])%=mod;
				(dp[i + 1][1][k][i] += dp[i][2][k][l])%=mod;
				(dp[i + 1][2][i][l] += dp[i][0][k][l])%=mod;
				(dp[i + 1][2][k][i] += dp[i][1][k][l]) %= mod;
			}
		}
		rep(j, (int)v[i].size()) {
			int le = v[i][j].first; int c = v[i][j].second;
			rep(k, i + 1) {
				rep(l, i + 1) {
					rep(m, 3) {
						if (c == 1) {
							if (k >= le || l >= le)dp[i + 1][m][k][l] = 0;
						}
						if (c == 2) {
							if ((k >= le && l >= le) || (k < le&&l < le))dp[i + 1][m][k][l] = 0;
						}
						if (c == 3) {
							if (k < le || l < le)dp[i + 1][m][k][l] = 0;
						}
					}
				}
			}
		}
	}
	ll out = 0;
	rep(j, 3) {
		rep(k, n) {
			rep(l, n) {
				(out += dp[n][j][k][l]) %= mod;
				//cout << j << " " << k << " " << l << " " << dp[n][j][k][l] << endl;
			}
		}
	}
	out = out * ((mod+1) / 3) % mod;
	cout << out << endl;
	return 0;
}

Submission Info

Submission Time
Task E - RGB Sequence
User heno239
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2308 Byte
Status MLE
Exec Time 417 ms
Memory 633216 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 4
AC × 4
MLE × 43
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 3 ms 6400 KB
0_01.txt AC 2 ms 8448 KB
0_02.txt AC 1 ms 2304 KB
0_03.txt AC 5 ms 16640 KB
1_00.txt MLE 405 ms 624896 KB
1_01.txt MLE 376 ms 628992 KB
1_02.txt MLE 361 ms 633216 KB
1_03.txt MLE 416 ms 628992 KB
1_04.txt MLE 417 ms 633216 KB
1_05.txt MLE 372 ms 626944 KB
1_06.txt MLE 357 ms 633216 KB
1_07.txt MLE 368 ms 626944 KB
1_08.txt MLE 406 ms 626944 KB
1_09.txt MLE 367 ms 628992 KB
1_10.txt MLE 345 ms 622848 KB
1_11.txt MLE 360 ms 622848 KB
1_12.txt MLE 383 ms 610560 KB
1_13.txt MLE 370 ms 633216 KB
1_14.txt MLE 353 ms 626944 KB
1_15.txt MLE 411 ms 631040 KB
1_16.txt MLE 415 ms 628992 KB
1_17.txt MLE 381 ms 633216 KB
1_18.txt MLE 342 ms 626944 KB
1_19.txt MLE 347 ms 626944 KB
1_20.txt MLE 385 ms 622848 KB
1_21.txt MLE 368 ms 633216 KB
1_22.txt MLE 346 ms 631040 KB
1_23.txt MLE 407 ms 628992 KB
1_24.txt MLE 406 ms 628992 KB
1_25.txt MLE 361 ms 633216 KB
1_26.txt MLE 328 ms 616704 KB
1_27.txt MLE 340 ms 628992 KB
1_28.txt MLE 401 ms 628992 KB
1_29.txt MLE 354 ms 631040 KB
1_30.txt MLE 336 ms 624896 KB
1_31.txt MLE 388 ms 618752 KB
1_32.txt MLE 417 ms 631040 KB
1_33.txt MLE 354 ms 633216 KB
1_34.txt MLE 334 ms 618752 KB
1_35.txt MLE 341 ms 626944 KB
1_36.txt MLE 404 ms 608512 KB
1_37.txt MLE 352 ms 626944 KB
1_38.txt MLE 345 ms 633216 KB
1_39.txt MLE 357 ms 633216 KB
1_40.txt MLE 343 ms 633216 KB
1_41.txt MLE 370 ms 633216 KB
1_42.txt MLE 378 ms 633216 KB