# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
56312 |
2018-07-11T04:38:23 Z |
정원준(#1601) |
Tents (JOI18_tents) |
C++11 |
|
133 ms |
71788 KB |
/*#include <bits/stdc++.h>
#define L long long
using namespace std;
L ans;
L n,m;
L a[3333][3333];
bool ok(L x,L y,L num){
L i;
for(i=1;i<x;i++)
{
if(num==2)
{
if(a[i][y]&&a[i][y]!=1) return 0;
}
else
{
if(a[i][y]) return 0;
}
}
for(i=1;i<y;i++)
{
if(num==4)
{
if(a[x][i]&&a[x][i]!=3) return 0;
}
else
{
if(a[x][i]) return 0;
}
}
return 1;
}
L dfs(L x,L y,L n,L m){
L ret=0;
if(y>m)
{
x++;
y-=m;
if(x>n)
{
return 1;
}
}
if(ok(x,y,1))
{
a[x][y]=1;
ret+=dfs(x,y+1,n,m);
a[x][y]=0;
}
if(ok(x,y,2))
{
a[x][y]=2;
ret+=dfs(x,y+1,n,m);
a[x][y]=0;
}
if(ok(x,y,3))
{
a[x][y]=3;
ret+=dfs(x,y+1,n,m);
a[x][y]=0;
}
if(ok(x,y,4))
{
a[x][y]=4;
ret+=dfs(x,y+1,n,m);
a[x][y]=0;
}
ret+=dfs(x,y+1,n,m);
return ret;
}
int main()
{
scanf("%lld %lld",&n,&m);
L i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
printf("%lld ",dfs(1,1,i,j));
}
puts("");
}
}*/
#include <bits/stdc++.h>
#define L long long
#define mod 1000000007
using namespace std;
L dp[3030][3030];
L n,m;
int main()
{
scanf("%lld %lld",&n,&m);
if(n>m) swap(n,m);
L i,j;
for(i=0;i<=m;i++)
{
dp[0][i]=dp[i][0]=1;
}
dp[1][1]=5;
for(i=2;i<=m;i++)
{
dp[1][i]=4*i+i*(i-1)*500000004+1;
dp[1][i]%=mod;
}
for(i=2;i<=n;i++)
{
dp[i][1]=dp[1][i];
for(j=2;j<=m;j++)
{
dp[i][j]=dp[i][j-1]+(dp[i-1][j-2]*(j-1)+dp[i-1][j-1]*4)*i+(dp[i-2][j-1]*i)*(i-1)%mod*500000004;
dp[i][j]%=mod;
//printf("%lld ",dp[i][j]);
}
//puts("");
}
printf("%lld",((dp[n][m]-1)%mod+mod)%mod);
}
Compilation message
tents.cpp: In function 'int main()':
tents.cpp:106:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld",&n,&m);
~~~~~^~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
1132 KB |
Output is correct |
3 |
Correct |
2 ms |
1132 KB |
Output is correct |
4 |
Correct |
2 ms |
1384 KB |
Output is correct |
5 |
Correct |
4 ms |
1824 KB |
Output is correct |
6 |
Correct |
3 ms |
1824 KB |
Output is correct |
7 |
Correct |
3 ms |
1824 KB |
Output is correct |
8 |
Correct |
3 ms |
1824 KB |
Output is correct |
9 |
Correct |
2 ms |
1824 KB |
Output is correct |
10 |
Correct |
4 ms |
2028 KB |
Output is correct |
11 |
Correct |
3 ms |
2028 KB |
Output is correct |
12 |
Correct |
4 ms |
2456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
1132 KB |
Output is correct |
3 |
Correct |
2 ms |
1132 KB |
Output is correct |
4 |
Correct |
2 ms |
1384 KB |
Output is correct |
5 |
Correct |
4 ms |
1824 KB |
Output is correct |
6 |
Correct |
3 ms |
1824 KB |
Output is correct |
7 |
Correct |
3 ms |
1824 KB |
Output is correct |
8 |
Correct |
3 ms |
1824 KB |
Output is correct |
9 |
Correct |
2 ms |
1824 KB |
Output is correct |
10 |
Correct |
4 ms |
2028 KB |
Output is correct |
11 |
Correct |
3 ms |
2028 KB |
Output is correct |
12 |
Correct |
4 ms |
2456 KB |
Output is correct |
13 |
Correct |
8 ms |
8044 KB |
Output is correct |
14 |
Correct |
11 ms |
9964 KB |
Output is correct |
15 |
Correct |
90 ms |
51540 KB |
Output is correct |
16 |
Correct |
11 ms |
51540 KB |
Output is correct |
17 |
Correct |
28 ms |
51540 KB |
Output is correct |
18 |
Correct |
29 ms |
51540 KB |
Output is correct |
19 |
Correct |
98 ms |
56364 KB |
Output is correct |
20 |
Correct |
77 ms |
56364 KB |
Output is correct |
21 |
Correct |
54 ms |
56364 KB |
Output is correct |
22 |
Correct |
54 ms |
56364 KB |
Output is correct |
23 |
Correct |
37 ms |
56364 KB |
Output is correct |
24 |
Correct |
133 ms |
71788 KB |
Output is correct |
25 |
Correct |
99 ms |
71788 KB |
Output is correct |
26 |
Correct |
114 ms |
71788 KB |
Output is correct |
27 |
Correct |
128 ms |
71788 KB |
Output is correct |