Submission #3015828
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=300+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
T ans=0,f=1;
char ch=getchar();
while(!isdigit(ch)&&ch!='-')ch=getchar();
if(ch=='-')f=-1,ch=getchar();
while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
return ans*f;
}
template<typename T>void write(T x,char y)
{
if(x==0)
{
putchar('0'),putchar(y);
return;
}
if(x<0)
{
putchar('-');
x=-x;
}
static char wr[20];
int top=0;
for(;x;x/=10)wr[++top]=x%10+'0';
while(top)putchar(wr[top--]);
putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
freopen("E.in","r",stdin);
freopen("E.out","w",stdout);
#endif
}
typedef pair<int,int>pii;
#define mk make_pair
#define fir first
#define sec second
#define pb push_back
vector<pii>q[N];
int n,m;
void input()
{
int l,r,x;
n=read<int>(),m=read<int>();
For(i,1,m)
{
l=read<int>(),r=read<int>(),x=read<int>();
q[r].pb(mk(l,x));
}
}
const int mo=1e9+7;
int dp[N][N][N];
void add(int &x,int y)
{
x+=y;x-=(x>=mo?mo:0);
}
void work()
{
int now,num,flag;
dp[0][0][0]=1;
int ans=0;
For(i,0,n)For(j,0,n)For(k,0,n)if(dp[i][j][k])
{
now=max(i,max(j,k));
flag=1;
for(pii t:q[now])
{
num=0;
num=(i>=t.fir)+(j>=t.fir)+(k>=t.fir);
if(num!=t.sec)flag=0;
}
if(flag==0)dp[i][j][k]=0;
else
{
add(dp[now+1][j][k],dp[i][j][k]);
add(dp[i][now+1][k],dp[i][j][k]);
add(dp[i][j][now+1],dp[i][j][k]);
}
if(now==n)add(ans,dp[i][j][k]);
}
write(ans,'\n');
}
int main()
{
//file();
input();
work();
return 0;
}
Submission Info
Submission Time |
|
Task |
E - RGB Sequence |
User |
dengyixuan |
Language |
C++14 (GCC 5.4.1) |
Score |
800 |
Code Size |
1988 Byte |
Status |
AC |
Exec Time |
295 ms |
Memory |
110848 KB |
Compile Error
./Main.cpp: In function ‘void file()’:
./Main.cpp:40:27: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen("E.in","r",stdin);
^
./Main.cpp:41:29: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen("E.out","w",stdout);
^
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 |
2432 KB |
1_00.txt |
AC |
48 ms |
107136 KB |
1_01.txt |
AC |
44 ms |
108928 KB |
1_02.txt |
AC |
44 ms |
108928 KB |
1_03.txt |
AC |
42 ms |
72064 KB |
1_04.txt |
AC |
54 ms |
109184 KB |
1_05.txt |
AC |
44 ms |
108928 KB |
1_06.txt |
AC |
44 ms |
108928 KB |
1_07.txt |
AC |
26 ms |
24960 KB |
1_08.txt |
AC |
49 ms |
109696 KB |
1_09.txt |
AC |
45 ms |
109312 KB |
1_10.txt |
AC |
50 ms |
108416 KB |
1_11.txt |
AC |
25 ms |
16896 KB |
1_12.txt |
AC |
47 ms |
105856 KB |
1_13.txt |
AC |
47 ms |
110336 KB |
1_14.txt |
AC |
50 ms |
109568 KB |
1_15.txt |
AC |
47 ms |
95232 KB |
1_16.txt |
AC |
53 ms |
108928 KB |
1_17.txt |
AC |
44 ms |
108928 KB |
1_18.txt |
AC |
47 ms |
108928 KB |
1_19.txt |
AC |
36 ms |
67968 KB |
1_20.txt |
AC |
49 ms |
107136 KB |
1_21.txt |
AC |
45 ms |
109184 KB |
1_22.txt |
AC |
53 ms |
110336 KB |
1_23.txt |
AC |
49 ms |
107008 KB |
1_24.txt |
AC |
50 ms |
110464 KB |
1_25.txt |
AC |
45 ms |
109184 KB |
1_26.txt |
AC |
47 ms |
107520 KB |
1_27.txt |
AC |
30 ms |
35712 KB |
1_28.txt |
AC |
49 ms |
109056 KB |
1_29.txt |
AC |
44 ms |
109056 KB |
1_30.txt |
AC |
48 ms |
107264 KB |
1_31.txt |
AC |
45 ms |
103040 KB |
1_32.txt |
AC |
48 ms |
109824 KB |
1_33.txt |
AC |
45 ms |
108928 KB |
1_34.txt |
AC |
47 ms |
108032 KB |
1_35.txt |
AC |
46 ms |
107520 KB |
1_36.txt |
AC |
42 ms |
105600 KB |
1_37.txt |
AC |
44 ms |
109312 KB |
1_38.txt |
AC |
48 ms |
109184 KB |
1_39.txt |
AC |
38 ms |
74624 KB |
1_40.txt |
AC |
295 ms |
110848 KB |
1_41.txt |
AC |
57 ms |
110848 KB |
1_42.txt |
AC |
43 ms |
108928 KB |