Submission #2549555
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 k, int r, int g, int b, int t, int r2, int g2, int b2) {
if(did[r][g][b][t]) return;
did[r][g][b][t] = 1;
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(dp[r][g][b] == 0) return;
calc(k, r, g, b, 0, k, g, b);
calc(k, r, g, b, 1, r, k, b);
calc(k, r, g, b, 2, 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;
if(dont[R][G][k]) continue;
calc0(k, R, G, B);
calc0(k, R, B, G);
calc0(k, G, R, B);
calc0(k, G, B, R);
calc0(k, B, R, G);
calc0(k, B, G, R);
}
}
}
ll res = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
res += dp[i][j][n];
res += dp[i][n][j];
res += dp[n][i][j];
}
}
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 |
2748 Byte |
Status |
WA |
Exec Time |
1298 ms |
Memory |
213376 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 |
WA |
2 ms |
4352 KB |
0_01.txt |
WA |
2 ms |
4352 KB |
0_02.txt |
AC |
1 ms |
256 KB |
0_03.txt |
WA |
2 ms |
4352 KB |
1_00.txt |
WA |
81 ms |
61696 KB |
1_01.txt |
WA |
89 ms |
108800 KB |
1_02.txt |
WA |
64 ms |
30976 KB |
1_03.txt |
AC |
68 ms |
39168 KB |
1_04.txt |
WA |
155 ms |
213248 KB |
1_05.txt |
WA |
60 ms |
41216 KB |
1_06.txt |
WA |
65 ms |
30976 KB |
1_07.txt |
AC |
76 ms |
73984 KB |
1_08.txt |
WA |
139 ms |
213248 KB |
1_09.txt |
WA |
62 ms |
35072 KB |
1_10.txt |
WA |
60 ms |
33024 KB |
1_11.txt |
AC |
73 ms |
59648 KB |
1_12.txt |
WA |
118 ms |
209024 KB |
1_13.txt |
WA |
101 ms |
116992 KB |
1_14.txt |
WA |
71 ms |
45312 KB |
1_15.txt |
AC |
139 ms |
188672 KB |
1_16.txt |
WA |
153 ms |
213248 KB |
1_17.txt |
WA |
69 ms |
53504 KB |
1_18.txt |
WA |
76 ms |
35072 KB |
1_19.txt |
AC |
72 ms |
35072 KB |
1_20.txt |
WA |
139 ms |
213120 KB |
1_21.txt |
WA |
83 ms |
65792 KB |
1_22.txt |
WA |
90 ms |
51456 KB |
1_23.txt |
AC |
141 ms |
209152 KB |
1_24.txt |
WA |
131 ms |
213248 KB |
1_25.txt |
WA |
72 ms |
41216 KB |
1_26.txt |
WA |
78 ms |
33024 KB |
1_27.txt |
AC |
13 ms |
26880 KB |
1_28.txt |
WA |
144 ms |
213248 KB |
1_29.txt |
WA |
145 ms |
213248 KB |
1_30.txt |
WA |
85 ms |
30976 KB |
1_31.txt |
AC |
135 ms |
206976 KB |
1_32.txt |
WA |
122 ms |
213248 KB |
1_33.txt |
WA |
148 ms |
213248 KB |
1_34.txt |
WA |
118 ms |
88320 KB |
1_35.txt |
AC |
173 ms |
180480 KB |
1_36.txt |
WA |
110 ms |
209024 KB |
1_37.txt |
WA |
147 ms |
213248 KB |
1_38.txt |
WA |
188 ms |
213376 KB |
1_39.txt |
AC |
138 ms |
155904 KB |
1_40.txt |
AC |
1298 ms |
187008 KB |
1_41.txt |
WA |
31 ms |
30976 KB |
1_42.txt |
WA |
31 ms |
30976 KB |