解题思路:
搬运的题解。
https://www.cnblogs.com/Jozky/p/13928002.html
注意事项:
参考代码:
n,m = map(int,input().strip().split()) mod = 1000000007 check = [[0 for j in range(m+1)] for i in range(n+1)] dp = [[0 for j in range(m+2)] for i in range(m+1)] for i in range(1,n+1): G = input() for j in range(1,m+1): check[i][j] = check[i][j-1] if G[j-1] == 'X': check[i][j] = check[i][j]+1 ans = 1 for i in range(1,m+1): for j in range(m,i-1,-1): if check[n][j] - check[n][i-1] == 0: ans = ans + 1 dp[i][j] = dp[i][j+1]+dp[i-1][j]-dp[i-1][j+1]+1 for t in range(n-1,0,-1): for i in range(1,m+1): for j in range(m,i-1,-1): if check[t][j] - check[t][i-1] == 0: ans = (ans+dp[i][j]) % mod dp[i][j] = (dp[i][j] + dp[i-1][j]+dp[i][j+1]-dp[i-1][j+1]) % mod else: dp[i][j] = 0 print(ans)
0.0分
2 人评分
C语言程序设计教程(第三版)课后习题7.2 (Java代码)浏览:694 |
九宫重排 (C++代码)浏览:2195 |
C语言训练-角谷猜想 (C语言代码)浏览:1768 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:782 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:806 |
C语言程序设计教程(第三版)课后习题9.3 (C语言代码)浏览:650 |
链表数据求和操作 (C语言代码)浏览:1035 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:841 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:669 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:461 |