Submission #3775731
Source Code Expand
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
inline int read()
{
int res = 0; bool bo = 0; char c;
while (((c = getchar()) < '0' || c > '9') && c != '-');
if (c == '-') bo = 1; else res = c - 48;
while ((c = getchar()) >= '0' && c <= '9')
res = (res << 3) + (res << 1) + (c - 48);
return bo ? ~res + 1 : res;
}
template <class T>
inline T Min(const T &a, const T &b) {return a < b ? a : b;}
template <class T>
inline T Max(const T &a, const T &b) {return a > b ? a : b;}
const int N = 305, INF = 0x3f3f3f3f, ZZQ = 1e9 + 7;
int n, m, min1[N], min2[N], max2[N], max3[N], f[N][N][N], ans;
bool check(int i, int j, int k)
{
return min1[i] >= j && min2[i] >= k && max2[i] < j && max3[i] < k;
}
int main()
{
int i, j, k, l, r, x;
n = read(); m = read();
For (i, 1, n) min1[i] = min2[i] = INF, max2[i] = max3[i] = -INF;
while (m--)
{
l = read(); r = read(); x = read();
if (x == 1) min1[r] = Min(min1[r], l);
else if (x == 2)
min2[r] = Min(min2[r], l), max2[r] = Max(max2[r], l);
else max3[r] = Max(max3[r], l);
}
f[1][1][0] = max2[1] == -INF && max3[1] == -INF ? 3 : 0;
For (i, 1, n - 1) For (j, 0, i) For (k, 0, i)
{
if (!f[i][j][k]) continue;
if (check(i + 1, j, k))
f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % ZZQ;
if (k)
{
if (check(i + 1, i + 1, k))
f[i + 1][i + 1][k] = (f[i + 1][i + 1][k] + f[i][j][k]) % ZZQ;
if (check(i + 1, i + 1, j))
f[i + 1][i + 1][j] = (f[i + 1][i + 1][j] + f[i][j][k]) % ZZQ;
}
else
{
if (check(i + 1, i + 1, j))
f[i + 1][i + 1][j] = (2ll * f[i][j][k]
+ f[i + 1][i + 1][j]) % ZZQ;
}
}
For (j, 0, n) For (k, 0, j - 1)
ans = (ans + f[n][j][k]) % ZZQ;
std::cout << ans << std::endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - RGB Sequence |
User |
xyz32768 |
Language |
C++14 (GCC 5.4.1) |
Score |
800 |
Code Size |
1871 Byte |
Status |
AC |
Exec Time |
60 ms |
Memory |
108800 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
800 / 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 |
1 ms |
256 KB |
0_01.txt |
AC |
1 ms |
256 KB |
0_02.txt |
AC |
1 ms |
256 KB |
0_03.txt |
AC |
2 ms |
2304 KB |
1_00.txt |
AC |
29 ms |
106752 KB |
1_01.txt |
AC |
29 ms |
108800 KB |
1_02.txt |
AC |
29 ms |
108800 KB |
1_03.txt |
AC |
23 ms |
71936 KB |
1_04.txt |
AC |
30 ms |
108800 KB |
1_05.txt |
AC |
29 ms |
106752 KB |
1_06.txt |
AC |
29 ms |
108800 KB |
1_07.txt |
AC |
13 ms |
24832 KB |
1_08.txt |
AC |
29 ms |
106752 KB |
1_09.txt |
AC |
29 ms |
108800 KB |
1_10.txt |
AC |
29 ms |
106752 KB |
1_11.txt |
AC |
11 ms |
16640 KB |
1_12.txt |
AC |
28 ms |
104704 KB |
1_13.txt |
AC |
29 ms |
108800 KB |
1_14.txt |
AC |
29 ms |
106752 KB |
1_15.txt |
AC |
26 ms |
92416 KB |
1_16.txt |
AC |
30 ms |
108800 KB |
1_17.txt |
AC |
29 ms |
108800 KB |
1_18.txt |
AC |
29 ms |
106752 KB |
1_19.txt |
AC |
21 ms |
67840 KB |
1_20.txt |
AC |
29 ms |
106752 KB |
1_21.txt |
AC |
29 ms |
108800 KB |
1_22.txt |
AC |
30 ms |
108800 KB |
1_23.txt |
AC |
29 ms |
104704 KB |
1_24.txt |
AC |
29 ms |
108800 KB |
1_25.txt |
AC |
29 ms |
108800 KB |
1_26.txt |
AC |
28 ms |
104704 KB |
1_27.txt |
AC |
15 ms |
33024 KB |
1_28.txt |
AC |
29 ms |
108800 KB |
1_29.txt |
AC |
29 ms |
108800 KB |
1_30.txt |
AC |
29 ms |
106752 KB |
1_31.txt |
AC |
28 ms |
102656 KB |
1_32.txt |
AC |
29 ms |
108800 KB |
1_33.txt |
AC |
29 ms |
108800 KB |
1_34.txt |
AC |
29 ms |
106752 KB |
1_35.txt |
AC |
28 ms |
104704 KB |
1_36.txt |
AC |
28 ms |
104704 KB |
1_37.txt |
AC |
29 ms |
106752 KB |
1_38.txt |
AC |
29 ms |
108800 KB |
1_39.txt |
AC |
22 ms |
71936 KB |
1_40.txt |
AC |
60 ms |
108800 KB |
1_41.txt |
AC |
29 ms |
108800 KB |
1_42.txt |
AC |
29 ms |
108800 KB |