Submission #3429972
Source Code Expand
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
/*
wa
*/
struct rgb{
ll r,g,b;
};
bool operator<(const rgb &lhs, const rgb &rhs){//全順序を定義しなければいけない
if(lhs.r < rhs.r){
return true;
}else if(lhs.r == rhs.r){
if(lhs.g < rhs.g){
return true;
}else if(lhs.g == rhs.g){
if(lhs.b < rhs.b){
return true;
}
}
}
return false;
}
ll n,m,dp[310][310][310],ans=0;//(r,g,b)を最後に塗った場所
vector<mp> v[310];
set<rgb> s;
int main(void){
rep(i,310)rep(j,310)rep(k,310)dp[i][j][k]=0;
cin>>n>>m;
rep(i,m){
ll l,r,x;
cin>>l>>r>>x;
v[r].push_back(make_pair(l,x));
}
dp[0][0][0]=1;
s.insert({0,0,0});
reg(i,1,n+1){
set<rgb> t;//遷移先
for(auto itr = s.begin(); itr != s.end(); ++itr) {
rgb x = *itr;
ll r=x.r,g=x.g,b=x.b;
// printf("%lld,%lld,%lld\n",r,g,b);
bool ok=true;
rep(j,v[i-1].size()){
mp p=v[i-1][j];
ll c=p.first,d=p.second,cnt=0;//l,x
if(r>=c)cnt++;
if(g>=c)cnt++;
if(b>=c)cnt++;
if(cnt!=d){
ok=false;
break;
}
}
if(!ok)continue;
if(i==n+1){
ans+=dp[r][g][b];
}else{
dp[i][g][b]+=dp[r][g][b];
dp[r][i][b]+=dp[r][g][b];
dp[r][g][i]+=dp[r][g][b];
t.insert({i,g,b});
t.insert({r,i,b});
t.insert({r,g,i});
}
}
s=t;//遷移先の上書き
}
cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - RGB Sequence |
User |
RMQ |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1923 Byte |
Status |
WA |
Exec Time |
2105 ms |
Memory |
246144 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 |
60 ms |
232960 KB |
0_01.txt |
AC |
60 ms |
232960 KB |
0_02.txt |
AC |
60 ms |
232960 KB |
0_03.txt |
AC |
59 ms |
232960 KB |
1_00.txt |
WA |
184 ms |
233984 KB |
1_01.txt |
WA |
83 ms |
233088 KB |
1_02.txt |
WA |
69 ms |
233088 KB |
1_03.txt |
AC |
183 ms |
233984 KB |
1_04.txt |
WA |
258 ms |
234240 KB |
1_05.txt |
WA |
91 ms |
233216 KB |
1_06.txt |
WA |
72 ms |
233216 KB |
1_07.txt |
AC |
64 ms |
233088 KB |
1_08.txt |
WA |
143 ms |
233600 KB |
1_09.txt |
WA |
69 ms |
233088 KB |
1_10.txt |
WA |
143 ms |
233728 KB |
1_11.txt |
AC |
63 ms |
233088 KB |
1_12.txt |
WA |
128 ms |
233600 KB |
1_13.txt |
WA |
78 ms |
233088 KB |
1_14.txt |
WA |
151 ms |
233600 KB |
1_15.txt |
AC |
135 ms |
233472 KB |
1_16.txt |
WA |
271 ms |
234112 KB |
1_17.txt |
WA |
79 ms |
233088 KB |
1_18.txt |
WA |
100 ms |
233344 KB |
1_19.txt |
AC |
70 ms |
233088 KB |
1_20.txt |
WA |
171 ms |
233984 KB |
1_21.txt |
WA |
68 ms |
233088 KB |
1_22.txt |
WA |
164 ms |
233600 KB |
1_23.txt |
AC |
149 ms |
233600 KB |
1_24.txt |
WA |
147 ms |
233600 KB |
1_25.txt |
WA |
66 ms |
233088 KB |
1_26.txt |
WA |
112 ms |
233344 KB |
1_27.txt |
AC |
71 ms |
233088 KB |
1_28.txt |
WA |
124 ms |
233600 KB |
1_29.txt |
AC |
65 ms |
233088 KB |
1_30.txt |
WA |
116 ms |
233344 KB |
1_31.txt |
AC |
108 ms |
233600 KB |
1_32.txt |
WA |
110 ms |
233856 KB |
1_33.txt |
AC |
67 ms |
233088 KB |
1_34.txt |
WA |
117 ms |
233344 KB |
1_35.txt |
AC |
106 ms |
233344 KB |
1_36.txt |
AC |
79 ms |
233344 KB |
1_37.txt |
AC |
61 ms |
233088 KB |
1_38.txt |
AC |
100 ms |
233216 KB |
1_39.txt |
AC |
63 ms |
233088 KB |
1_40.txt |
TLE |
2105 ms |
246144 KB |
1_41.txt |
WA |
151 ms |
233472 KB |
1_42.txt |
AC |
61 ms |
232960 KB |