Submission #1518638
Source Code Expand
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
#include <memory.h>
#include <iomanip>
using namespace std;
#define maxn 302
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
const ll MOD = 1000000007;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}
int n, m;
ll f[maxn][maxn][maxn];
vector<ii> R[maxn];
bool check(int i, int x, int y, int z) {
REP(j, R[i].sz()) {
int l = R[i][j].fi, T = R[i][j].se, cnt = 0;
if (x>=l) ++cnt;
if (y>=l) ++cnt;
if (z>=l) ++cnt;
if (cnt!=T) return false;
}
return true;
}
ll dp(int x, int y, int z) {
if (f[x][y][z]>-1) return f[x][y][z];
int i = max(max(x, y), z);
if (i==n) return check(i, x, y, z);
if (!check(i, x, y, z)) return f[x][y][z] = 0;
return f[x][y][z] = (dp(i+1, y, z) + dp(x, i+1, z) + dp(x, y, i+1))%MOD;
}
int main() {
//freopen("rbg.inp", "r", stdin);
//freopen("", "w", stdout);
//ios::sync_with_stdio(0); cin.tie(0);
scanf("%d%d", &n, &m);
memset(f, -1, sizeof(f));
while (m--) {
int l, r, x; scanf("%d%d%d", &l, &r, &x);
R[r].push_back(ii(l, x));
}
//Debug(dp(0, 0, 1));
//cout << (dp(0, 0, 1) + dp(0, 1, 0) + dp(1, 0, 0))%MOD;
cout << dp(0, 0, 1)*3%MOD;
}
Submission Info
Submission Time |
|
Task |
E - RGB Sequence |
User |
phong22kk11 |
Language |
C++14 (GCC 5.4.1) |
Score |
800 |
Code Size |
2295 Byte |
Status |
AC |
Exec Time |
959 ms |
Memory |
215552 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:69:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
./Main.cpp:72:49: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int l, r, x; scanf("%d%d%d", &l, &r, &x);
^
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 |
53 ms |
215424 KB |
0_01.txt |
AC |
53 ms |
215424 KB |
0_02.txt |
AC |
53 ms |
215424 KB |
0_03.txt |
AC |
53 ms |
215424 KB |
1_00.txt |
AC |
67 ms |
215424 KB |
1_01.txt |
AC |
56 ms |
215424 KB |
1_02.txt |
AC |
55 ms |
215424 KB |
1_03.txt |
AC |
66 ms |
215424 KB |
1_04.txt |
AC |
74 ms |
215424 KB |
1_05.txt |
AC |
58 ms |
215424 KB |
1_06.txt |
AC |
55 ms |
215424 KB |
1_07.txt |
AC |
54 ms |
215424 KB |
1_08.txt |
AC |
62 ms |
215424 KB |
1_09.txt |
AC |
54 ms |
215424 KB |
1_10.txt |
AC |
65 ms |
215424 KB |
1_11.txt |
AC |
54 ms |
215424 KB |
1_12.txt |
AC |
60 ms |
215424 KB |
1_13.txt |
AC |
56 ms |
215424 KB |
1_14.txt |
AC |
66 ms |
215424 KB |
1_15.txt |
AC |
62 ms |
215424 KB |
1_16.txt |
AC |
76 ms |
215424 KB |
1_17.txt |
AC |
56 ms |
215424 KB |
1_18.txt |
AC |
59 ms |
215424 KB |
1_19.txt |
AC |
55 ms |
215424 KB |
1_20.txt |
AC |
66 ms |
215424 KB |
1_21.txt |
AC |
54 ms |
215424 KB |
1_22.txt |
AC |
68 ms |
215424 KB |
1_23.txt |
AC |
64 ms |
215424 KB |
1_24.txt |
AC |
63 ms |
215424 KB |
1_25.txt |
AC |
54 ms |
215424 KB |
1_26.txt |
AC |
61 ms |
215424 KB |
1_27.txt |
AC |
55 ms |
215424 KB |
1_28.txt |
AC |
61 ms |
215424 KB |
1_29.txt |
AC |
55 ms |
215424 KB |
1_30.txt |
AC |
62 ms |
215552 KB |
1_31.txt |
AC |
59 ms |
215424 KB |
1_32.txt |
AC |
58 ms |
215424 KB |
1_33.txt |
AC |
54 ms |
215424 KB |
1_34.txt |
AC |
62 ms |
215424 KB |
1_35.txt |
AC |
60 ms |
215424 KB |
1_36.txt |
AC |
56 ms |
215424 KB |
1_37.txt |
AC |
53 ms |
215424 KB |
1_38.txt |
AC |
59 ms |
215424 KB |
1_39.txt |
AC |
54 ms |
215424 KB |
1_40.txt |
AC |
959 ms |
215424 KB |
1_41.txt |
AC |
68 ms |
215424 KB |
1_42.txt |
AC |
53 ms |
215424 KB |