Your Ways

本文探讨了在城市规划中如何通过路径规划算法解决道路阻塞问题,特别关注于如何仅沿东西和南北方向行走以到达目的地,同时避免已阻塞的街道和大道。文章提供了一个实例,说明如何计算在给定天数内到达特定目的地的不同路径数量,并在遇到道路阻塞时进行调整。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >




 You live in a small well-planned rectangular town in Phuket. The size of the central area of the town is H kilometers x W kilometers. The central area is divided into HW unit blocks, each of size 1 x 1 km2. There are H + 1 streets going in the West to East direction, and there are W + 1 avenue going in the North-South direction. The central area can be seen as a rectangle on the plane, as shown below.

We can identify each intersection by its co-ordinate on the plane. For example, on the Figure above the bottom-left corner is intersection (0,0), and the top-right corner is intersection (6,3).
Your house is at the bottom-left corner (i.e., intersection (0,0)) and you want to go to the university at the top-right corner (i.e., intersection (W,H)). More over, you only want to go to the university with wasting any efforts; therefore, you only want to walk from West-to-East and South-to-North directions. Walking this way, in the example above there are 84 ways to reach the university.
You want to go to the university for K days. Things get more complicated when each morning, the city blocks parts of streets and avenues to do some cleaning. The blocking is done in such a way that it is not possible to reach parts of the streets or avenues which is blocked from some other part which is blocked as well through any paths containing only West-to-East and South-to-North walks.
You still want to go to the university using the same West-to-East and South-to-North strategy. You want to find out for each day, how many ways you can reach the university by only walking West-to-East and South-to-North. Since the number can be very big, we only want the result modulo 2552.

Input

The first line contains an integer T, the number of test cases (1 <= T <= 5). Each test case is in the following format.

The first line of each test case contains 3 integers: W, H, and K (1 <= W <= 1,000; 1 <= H <= 1,000; 1 <= K <= 10,000). W and H specify the size of the central area. K denotes the number of days you want to go to the university.
The next K lines describe the information on broken parts of streets and avenues. More specifically, line 1 + i, for 1 <= i <= K, starts with an integer Qi(1 <= Qi <= 100) denoting the number of parts which are blocked. Then Qi sets of 4 integers describing the blocked parts follow. Each part is described with 4 integers, A, B, C, and D (0 <= A <= C <= W; 0 <= B <= D <= H) meaning that the parts connecting intersection (A,B) and (C,D) is blocked. It is guaranteed that that part is a valid part of the streets or avenues, also C - A <= 1, and D – B <= 1, i.e., the part is 1 km long.

Output

For each test case, for each day, your program must output the number of ways to go to the university modulo 2552 on a separate line. i.e., the output for each test case must contains K lines.

Sample Input

2
2 2 3
1 0 0 0 1
2 1 0 2 0 0 2 1 2
1 1 1 2 1
100 150 2
1 99 150 100 150
2 99 150 100 150 100 149 100 150

Sample Output

3
4
4
1562
0

Hint

The amount of I/O for this task is quite large. Therefore, when reading input, you should avoid using java.io.Scanner which is much slower than using java.io.BufferedReader. 

The blocking is done in such a way that it is not possible to reach parts of the streets or avenues which is blocked from some other part which is blocked as well through any paths containing only West-to-East and South-to-North walks.

这句话的意思是每条不能走的道路不会相互影响!所以可以用总数 - 两个端点所能到达的情况数!

<span style="font-size:14px;color:#ff0000;">#include<iostream>
#include<stack>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stdio.h>

using namespace std;

struct node
{
    int x1,y1,x2,y2;
}N[305];

int dp[1005][1005];

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int m,n,k;
        cin>>m>>n>>k;
        for(int i=0;i<=(m>n?m:n);i++)
            dp[i][0] = dp[0][i] = 1;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
        {
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%2552;
        }
        while(k--)
        {
            int ans = dp[n][m];
            int a;
            cin>>a;
            for(int i=0;i<a;i++)
            {
                cin>>N[i].x1>>N[i].y1>>N[i].x2>>N[i].y2;
                ans -= dp[N[i].y1][N[i].x1] * dp[n-N[i].y2][m-N[i].x2];
                ans = (ans+2552)%2552;
            }
        if(ans < 0)
            ans += 2552;
           cout<<ans<<endl;
        }
    }
    return 0;
}
</span>

内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值