这个评测是有问题吗 下测试数据下了检测是对的 判我WA是为啥呢 是第13个点

P2895 [USACO08FEB] Meteor Shower S

cd8gsh @ 2022-02-05 00:32:06


by cd8gsh @ 2022-02-05 00:33:24

#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

int m, x, y, t;
queue<int> q[2];
int Map[310][310], vis[310][310];
int dx[5] = {0, 1, 0, -1, 0};
int dy[5] = {0, 0, -1, 0, 1};
int main()
{
    freopen("2.in", "r", stdin);
    cin >> m;
    memset(Map, -1, sizeof(Map));
    memset(vis, -1, sizeof(vis));
    while (m--)
    {
        cin >> x >> y >> t;
        for (int i = 0; i < 5; i++)
            if (x + dx[i] >= 0 && y + dy[i] >= 0 && Map[x + dx[i]][y + dy[i]] > t || Map[x + dx[i]][y + dy[i]] == -1)
                Map[x + dx[i]][y + dy[i]] = t;
    }
    q[0].push(0);
    q[1].push(0);
    t = 0;
    vis[0][0] = 0;
    while (!q[1].empty())
    {
        x = q[0].front();
        y = q[1].front();
        t = vis[x][y];
        q[0].pop();
        q[1].pop();
        if (Map[x][y] == -1)
        {
            cout << t;
            return 0;
        }
        for (int i = 0; i < 5; i++)
        {
            if (x + dx[i] >= 0 && y + dy[i] >= 0 && vis[x + dx[i]][y + dy[i]] == -1 && (Map[x + dx[i]][y + dy[i]] > t + 1 || Map[x + dx[i]][y + dy[i]] == -1))
            {
                vis[x + dx[i]][y + dy[i]] = t + 1;
                q[0].push(x + dx[i]);
                q[1].push(y + dy[i]);
            }
        }
    }
    cout << -1;
    return 0;
}

by PerssonBrown @ 2022-02-05 00:41:10

@cd8gsh

您的代码使用题目提供的样例在洛谷IDE上的结果为 0 呢?


by coldy_rainy @ 2022-02-05 00:50:32

@cd8gsh

freopen("2.in", "r", stdin); 去掉即可


by coldy_rainy @ 2022-02-05 00:55:17

@cd8gsh

哦,还要加long long,不然会WA

半夜卷题的dalao%%%


by Feichuan @ 2022-02-05 01:05:13

不知道实名认证在哪,我就试试


by rzh123 @ 2022-02-05 08:37:29

@Feichuan 能回复说明你已经认证过了


by cd8gsh @ 2022-02-07 16:03:02

@penhaochen 确实是Long long 的问题没想到会超int,谢谢大佬


|