洛谷离谱求助
  • 板块灌水区
  • 楼主chenruikai
  • 当前回复8
  • 已保存回复8
  • 发布时间2024/6/22 22:14
  • 上次更新2024/6/23 10:00:58
查看原帖
洛谷离谱求助
1041549
chenruikai楼主2024/6/22 22:14

我在提交 p1941p1941 时,洛谷温馨提示编译错误,可是在本地编译(准确的讲是在 judge0IDEjudge0\Box IDE 上)是可以过的。这是撒子情况?

附注:不才的代码

/*
f(x , y) => pos(x , y) , least click_num;
f(x , y) = min(f(x - 1 , y - n * rise) , f(x - 1 , y + down));
*/
#include <bits/stdc++.h>
using namespace std;

#define debug 0
#define puterr(...) if(debug)printf(__VA_ARGS__)
#define debugpart if(debug)
#define unclear -1
#define cinf 0x3fffffff
struct pipe_type
{
    int up;
    int down;
};
int width , height , pipe_num;
int rise[10001] , down[10001];
pipe_type pipe[10001];
int mem[1001][2];
bool check(int x , int y)//in one of the pipes?
{
    return (pipe[x].up <= y || pipe[x].down >= y);
}
#define min3(a , b , c) min((a) , min((b) , (c)))
int main()
{
    cin >> width >> height >> pipe_num;
    for(int i = 0;i < width;i++)
    {
        cin >> rise[i] >> down[i];
    }
    for(int i = 0;i <= width;i++)
    {
        pipe[i].up = cinf;
        pipe[i].down = -cinf;
    }
    for(int i = 0;i < pipe_num;i++)
    {
        int x = 0 , up , down;
        cin >> x >> down >> up;
        // puterr("x = %d , up = %d , down = %d\n" , x , up , down);
        pipe[x].down = down;
        pipe[x].up = up;
    }
    mem[0][0] = cinf;
    for(int i = 1;i <= height;i++)
        mem[i][0] = 0;
    bool suc;
    int x;
    for(x = 1;x <= width;x++)
    {
        // mem[0][x & 1] = cinf;
        // int y = 1;
        // for(;y <= height && check(x , y) == true;y++)
        //     mem[y][x & 1] = cinf;
        // mem[y][x & 1] = cinf;
        // for(int n = 1;y - n * rise[x - 1] >= 0;n++)
        //     mem[y][x & 1] = min(mem[y][(x - 1) & 1] , 
        //         mem[y - n * rise[x - 1]][(x - 1) & 1] + n);
        // mem[y][x & 1] = min(mem[y][x & 1] , y + down[x - 1] <= height ? 
        //     mem[y + down[x - 1]][(x - 1) & 1] : cinf);
        // for(y++;y <= height;y++)
        // {
        //     if(check(x , y) == true)
        //     {
        //         mem[y][x & 1] = cinf;
        //         continue;
        //     }
        //     mem[y][x & 1] = min3(mem[y - rise[x - 1]][x & 1] + 1 , 
        //         mem[y - rise[x - 1]][(x - 1) & 1] + 1 , 
        //         y + down[x - 1] <= height ? mem[y + down[x - 1]][(x - 1) & 1] : cinf);
        // }
        mem[0][x & 1] = cinf;
        for(int y = 1;y <= height;y++)
        {
            if(check(x , y) == true)
            {
                mem[y][x & 1] = cinf;
                continue;
            }
            mem[y][x & 1] = cinf;
            if(y - rise[x - 1] > 0)
                mem[y][x & 1] = min(mem[y - rise[x - 1]][(x - 1) & 1] , 
                    mem[y - rise[x - 1]][x & 1]) + 1;
            if(y + down[x - 1] <= height)
                mem[y][x & 1] = min(mem[y][x & 1] , 
                    mem[y + down[x - 1]][(x - 1) & 1]);
            mem[y][x & 1] = min(mem[y][x & 1] , cinf);
        }
        // debugpart
        // {
        //     cout << "x = " << x << "\t";
        //     for(int i = 0;i <= height;i++)
        //     {
        //         if(mem[i][x & 1] == cinf)printf("cinf ");
        //         else cout << mem[i][x & 1] << " ";
        //     }
        //     puts("");
        // }
        suc = false;
        for(int i = 1;i <= height;i++)
            if(mem[i][x & 1] != cinf)
            {
                suc = true;
                break;
            }
        if(suc == false)break;
    }
    if(suc == true)
    {
        cout << 1 << endl;
        int ans = cinf;
        for(int i = 0;i <= height;i++)
            ans = min(mem[i][width & 1] , ans);
        cout << ans << endl;
    }
    else
    {
        cout << 0 << endl;
        int ans = 0;
        for(x--;x >= 0;x--)
        {
            if(pipe[x].up != cinf)
                ans++;
        }
        cout << ans << endl;
    }
    return 0;
}
2024/6/22 22:14
加载中...