Submission #3429674


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[3][300][300],cop[3][300][300];
vector<P> v[300];
int main() {
	rep(j, 3) {
		dp[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) {
					cop[j][k][l] = 0;
				}
			}
		}
		rep(k, i + 1) {
			rep(l, i + 1) {
				rep(j, 3) {
					(cop[j][k][l] += dp[j][k][l])%=mod;
				}
				(cop[0][i][l] += dp[1][k][l]) %= mod;
				(cop[0][k][i] += dp[2][k][l]) %= mod;
				(cop[1][i][l] += dp[0][k][l])%=mod;
				(cop[1][k][i] += dp[2][k][l])%=mod;
				(cop[2][i][l] += dp[0][k][l])%=mod;
				(cop[2][k][i] += dp[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)cop[m][k][l] = 0;
						}
						if (c == 2) {
							if ((k >= le && l >= le) || (k < le&&l < le))cop[m][k][l] = 0;
						}
						if (c == 3) {
							if (k < le || l < le)cop[m][k][l] = 0;
						}
					}
				}
			}
		}
		rep(k, i + 1) {
			rep(l, i + 1) {
				rep(j, 3) {
					dp[j][k][l] = cop[j][k][l];
				}
			}
		}
	}
	ll out = 0;
	rep(j, 3) {
		rep(k, n) {
			rep(l, n) {
				(out += dp[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 800
Code Size 2439 Byte
Status AC
Exec Time 319 ms
Memory 4480 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 2304 KB
0_01.txt AC 1 ms 2304 KB
0_02.txt AC 1 ms 2304 KB
0_03.txt AC 1 ms 2304 KB
1_00.txt AC 285 ms 4480 KB
1_01.txt AC 253 ms 4480 KB
1_02.txt AC 249 ms 4480 KB
1_03.txt AC 295 ms 4480 KB
1_04.txt AC 297 ms 4480 KB
1_05.txt AC 255 ms 4480 KB
1_06.txt AC 246 ms 4480 KB
1_07.txt AC 260 ms 4480 KB
1_08.txt AC 294 ms 4480 KB
1_09.txt AC 270 ms 4480 KB
1_10.txt AC 239 ms 4480 KB
1_11.txt AC 254 ms 4480 KB
1_12.txt AC 296 ms 4352 KB
1_13.txt AC 272 ms 4480 KB
1_14.txt AC 248 ms 4480 KB
1_15.txt AC 303 ms 4480 KB
1_16.txt AC 295 ms 4480 KB
1_17.txt AC 261 ms 4480 KB
1_18.txt AC 234 ms 4480 KB
1_19.txt AC 239 ms 4480 KB
1_20.txt AC 291 ms 4480 KB
1_21.txt AC 259 ms 4480 KB
1_22.txt AC 239 ms 4480 KB
1_23.txt AC 297 ms 4480 KB
1_24.txt AC 319 ms 4480 KB
1_25.txt AC 260 ms 4480 KB
1_26.txt AC 223 ms 4480 KB
1_27.txt AC 233 ms 4480 KB
1_28.txt AC 290 ms 4480 KB
1_29.txt AC 245 ms 4480 KB
1_30.txt AC 229 ms 4480 KB
1_31.txt AC 278 ms 4480 KB
1_32.txt AC 299 ms 4480 KB
1_33.txt AC 242 ms 4480 KB
1_34.txt AC 228 ms 4480 KB
1_35.txt AC 233 ms 4480 KB
1_36.txt AC 243 ms 4352 KB
1_37.txt AC 234 ms 4480 KB
1_38.txt AC 236 ms 4480 KB
1_39.txt AC 240 ms 4480 KB
1_40.txt AC 235 ms 4480 KB
1_41.txt AC 266 ms 4480 KB
1_42.txt AC 251 ms 4480 KB