Submission #2100772
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
int main() {
int n, m, i, j, k;
cin >> n >> m;
vector<pair<pll, ll> > rlx(m);
for (i = 0; i < m; i++) {
cin >> rlx[i].first.second >> rlx[i].first.first >> rlx[i].second;
}
sort(rlx.begin(), rlx.end());
vector<vll> rgb(n + 1, vll(n + 1, vl(n + 1)));
rgb[0][0][0] = 1;
j = 0;
rep1(i, n) {
//*
rep(r, i) {
rep(g, i) {
(rgb[i][g][i - 1] += rgb[r][g][i - 1]) %= MOD;
(rgb[r][i][i - 1] += rgb[r][g][i - 1]) %= MOD;
(rgb[r][g][i] += rgb[r][g][i - 1]) %= MOD;
}
rep(b, i) {
(rgb[i][i - 1][b] += rgb[r][i - 1][b]) %= MOD;
(rgb[r][i - 1][i] += rgb[r][i - 1][b]) %= MOD;
(rgb[r][i][b] += rgb[r][i - 1][b]) %= MOD;
}
}
rep(g, i) {
rep(b, i) {
(rgb[i][g][b] += rgb[i - 1][g][b]) %= MOD;
(rgb[i - 1][i][b] += rgb[i - 1][g][b]) %= MOD;
(rgb[i - 1][g][i] += rgb[i - 1][g][b]) %= MOD;
}
}
//*/
if (i == 1) {
rgb[0][0][1] /= 3;
rgb[0][1][0] /= 3;
rgb[1][0][0] /= 3;
}
while (j < m && i == rlx[j].first.first) {
int x = rlx[j].second;
int l = rlx[j].first.second;
if (x == 1) {
for (int g = l; g <= i; g++) {
for (int b = 0; b <= i; b++) {
rgb[i][g][b] = rgb[i][b][g] = 0;
rgb[g][i][b] = rgb[b][i][g] = 0;
rgb[g][b][i] = rgb[b][g][i] = 0;
}
}
}
else if (x == 2) {
for (int g = l; g <= i; g++) {
for (int b = l; b <= i; b++) {
rgb[i][g][b] = 0;
rgb[g][i][b] = 0;
rgb[i][g][b] = 0;
}
}
for (int g = 0; g < l; g++) {
for (int b = 0; b < l; b++) {
rgb[i][g][b] = 0;
rgb[g][i][b] = 0;
rgb[g][b][i] = 0;
}
}
}
else {
for (int g = 0; g < i; g++) {
for (int b = 0; b < l; b++) {
rgb[i][g][b] = rgb[i][b][g] = 0;
rgb[g][i][b] = rgb[b][i][g] = 0;
rgb[g][b][i] = rgb[b][g][i] = 0;
}
}
}
j++;
}
/*
rep(r, i + 1) {
rep(g, i + 1) {
rep(b, i + 1) {
cout << rgb[r][g][b] << " ";
}
cout << endl;
}
cout << endl;
}
//*/
}
ll ans = 0;
rep(g, n + 1) {
rep(b, n + 1) {
(ans += rgb[n][g][b]);
(ans += rgb[g][n][b]);
(ans += rgb[b][g][n]);
}
}
cout << ans << endl;
}
Submission Info
Submission Time |
|
Task |
E - RGB Sequence |
User |
fuppy0716 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
3207 Byte |
Status |
WA |
Exec Time |
1383 ms |
Memory |
216960 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 |
1 ms |
256 KB |
0_01.txt |
AC |
1 ms |
256 KB |
0_02.txt |
AC |
1 ms |
256 KB |
0_03.txt |
WA |
1 ms |
256 KB |
1_00.txt |
WA |
753 ms |
208384 KB |
1_01.txt |
WA |
1032 ms |
212608 KB |
1_02.txt |
WA |
648 ms |
216832 KB |
1_03.txt |
WA |
784 ms |
212608 KB |
1_04.txt |
WA |
742 ms |
216832 KB |
1_05.txt |
WA |
895 ms |
211200 KB |
1_06.txt |
WA |
587 ms |
216832 KB |
1_07.txt |
WA |
705 ms |
211200 KB |
1_08.txt |
WA |
608 ms |
213248 KB |
1_09.txt |
WA |
515 ms |
212608 KB |
1_10.txt |
WA |
484 ms |
206976 KB |
1_11.txt |
WA |
630 ms |
206976 KB |
1_12.txt |
WA |
422 ms |
194816 KB |
1_13.txt |
WA |
513 ms |
216832 KB |
1_14.txt |
WA |
477 ms |
211200 KB |
1_15.txt |
AC |
544 ms |
215552 KB |
1_16.txt |
WA |
741 ms |
212608 KB |
1_17.txt |
WA |
991 ms |
216832 KB |
1_18.txt |
WA |
461 ms |
211200 KB |
1_19.txt |
WA |
486 ms |
211200 KB |
1_20.txt |
WA |
443 ms |
206976 KB |
1_21.txt |
WA |
645 ms |
216832 KB |
1_22.txt |
WA |
433 ms |
215424 KB |
1_23.txt |
AC |
575 ms |
212608 KB |
1_24.txt |
WA |
456 ms |
212608 KB |
1_25.txt |
WA |
481 ms |
216832 KB |
1_26.txt |
WA |
395 ms |
200192 KB |
1_27.txt |
AC |
423 ms |
212608 KB |
1_28.txt |
WA |
533 ms |
212608 KB |
1_29.txt |
WA |
476 ms |
215424 KB |
1_30.txt |
WA |
404 ms |
208384 KB |
1_31.txt |
AC |
540 ms |
202880 KB |
1_32.txt |
WA |
804 ms |
215424 KB |
1_33.txt |
WA |
490 ms |
216832 KB |
1_34.txt |
WA |
383 ms |
202880 KB |
1_35.txt |
AC |
409 ms |
211200 KB |
1_36.txt |
AC |
1383 ms |
192128 KB |
1_37.txt |
AC |
511 ms |
211200 KB |
1_38.txt |
WA |
415 ms |
216832 KB |
1_39.txt |
AC |
525 ms |
216832 KB |
1_40.txt |
WA |
403 ms |
216832 KB |
1_41.txt |
WA |
542 ms |
216960 KB |
1_42.txt |
AC |
1256 ms |
216832 KB |