Submission #2549567
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dp[301][301][301];
bool did[301][301][301][3];
bool dont[301][301][301];
short cond[301][301];
ll mod = 1e9 + 7;
// #undef DEBUG
// #define DEBUG
/// {{{ DEBUG --- ///
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if(&o == &cerr) { o << '{'; for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? ", " : ""); o << "}"; } else { for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? " " : ""); } return o; }
#ifdef DEBUG
#define dump(...) (cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
#else
#define dump(...) (0)
#endif
/// }}}--- ///
void calc(int r, int g, int b, int r2, int g2, int b2) {
if(dont[r2][g2][b2]) return;
dp[r2][g2][b2] = ((ll) dp[r2][g2][b2] + dp[r][g][b]) % mod;
}
void calc0(int k, int r, int g, int b) {
if(r == g) {
if(g == b) {
calc(r, g, b, r, g, k);
} else {
calc(r, g, b, g, b, k);
calc(r, g, b, r, g, k);
}
} else {
calc(r, g, b, g, b, k);
calc(r, g, b, r, b, k);
calc(r, g, b, r, g, k);
}
}
int solve() {
ios::sync_with_stdio(false), cin.tie(0);
int n, m; cin >> n >> m;
for(int i = 0; i < m; i++) {
int l, r, x; cin >> l >> r >> x;
if(cond[l][r] != 0 && cond[l][r] != x) return 0;
cond[l][r] = x;
for(int G = 0; G < r; G++) for(int R = 0; R <= G; R++) {
if(G == R && R != 0) continue;
switch(x) {
case 1: if(G >= l) dont[R][G][r] = 1; break;
case 2: if(R >= l || l > G) dont[R][G][r] = 1; break;
case 3: if(l > R) dont[R][G][r] = 1; break;
}
}
}
dp[0][0][0] = 1;
for(int k = 1; k <= n; k++) {
int B = k - 1;
for(int G = 0; G <= B; G++) {
if(B == G && G != 0) continue;
for(int R = 0; R <= G; R++) {
if(G == R && R != 0) continue;
calc0(k, R, G, B);
}
}
}
ll res = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
res += dp[i][j][n];
}
}
res *= 6;
res %= mod;
return res;
}
int main() {
cout << solve() << endl;
}
Submission Info
Submission Time |
|
Task |
E - RGB Sequence |
User |
luma |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2614 Byte |
Status |
WA |
Exec Time |
247 ms |
Memory |
135424 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 800 |
Status |
|
|
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 |
2 ms |
2304 KB |
0_01.txt |
AC |
2 ms |
2304 KB |
0_02.txt |
AC |
1 ms |
256 KB |
0_03.txt |
AC |
2 ms |
4352 KB |
1_00.txt |
AC |
186 ms |
131328 KB |
1_01.txt |
AC |
160 ms |
133376 KB |
1_02.txt |
AC |
202 ms |
133376 KB |
1_03.txt |
AC |
189 ms |
131328 KB |
1_04.txt |
AC |
198 ms |
133376 KB |
1_05.txt |
AC |
169 ms |
133376 KB |
1_06.txt |
AC |
208 ms |
133376 KB |
1_07.txt |
AC |
185 ms |
133376 KB |
1_08.txt |
AC |
192 ms |
133376 KB |
1_09.txt |
AC |
213 ms |
131328 KB |
1_10.txt |
AC |
208 ms |
131328 KB |
1_11.txt |
AC |
190 ms |
131328 KB |
1_12.txt |
AC |
137 ms |
120960 KB |
1_13.txt |
AC |
216 ms |
135424 KB |
1_14.txt |
AC |
209 ms |
133376 KB |
1_15.txt |
AC |
202 ms |
131328 KB |
1_16.txt |
AC |
194 ms |
133376 KB |
1_17.txt |
AC |
172 ms |
133376 KB |
1_18.txt |
AC |
208 ms |
131328 KB |
1_19.txt |
AC |
206 ms |
133376 KB |
1_20.txt |
AC |
170 ms |
131200 KB |
1_21.txt |
AC |
187 ms |
135424 KB |
1_22.txt |
AC |
202 ms |
133376 KB |
1_23.txt |
AC |
194 ms |
133376 KB |
1_24.txt |
AC |
147 ms |
121088 KB |
1_25.txt |
AC |
198 ms |
133376 KB |
1_26.txt |
AC |
197 ms |
131328 KB |
1_27.txt |
AC |
13 ms |
26880 KB |
1_28.txt |
AC |
190 ms |
133376 KB |
1_29.txt |
AC |
177 ms |
133376 KB |
1_30.txt |
AC |
197 ms |
131328 KB |
1_31.txt |
AC |
178 ms |
131200 KB |
1_32.txt |
AC |
136 ms |
127232 KB |
1_33.txt |
AC |
181 ms |
135424 KB |
1_34.txt |
AC |
183 ms |
131328 KB |
1_35.txt |
AC |
195 ms |
133376 KB |
1_36.txt |
WA |
122 ms |
120960 KB |
1_37.txt |
WA |
171 ms |
131328 KB |
1_38.txt |
AC |
195 ms |
133376 KB |
1_39.txt |
AC |
175 ms |
135424 KB |
1_40.txt |
WA |
247 ms |
106880 KB |
1_41.txt |
AC |
218 ms |
133376 KB |
1_42.txt |
AC |
71 ms |
133376 KB |