QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#698864#8236. Snake Moveextreme1228Compile Error//C++201.9kb2024-11-01 22:45:362024-11-01 22:45:37

Judging History

你现在查看的是最新测评结果

  • [2024-11-01 22:45:37]
  • 评测
  • [2024-11-01 22:45:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
const int maxn = 3000 + 10;
int a[maxn][maxn];
int f[maxn][maxn];
int dis[maxn][maxn];
int vis[maxn][maxn];
const int INF = 1e18;
string b[maxn];

const int dx[] = {0,1,-1,0,0};
const int dy[] = {0,0,0,1,-1};

struct node{
    int x,y,t;
    friend bool operator < (const node & a,const node & b)
    {
        return a.t > b.t;
    }
};

void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    int x1,y1;
    for(int i=1;i<=k;i++){
        int x,y;
        cin>>x>>y;
        a[x][y] = k - i;
        if(i == 1){
            x1 = x,y1 = y;
        }
    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
        b[i] = ' ' + b[i];
    }
    priority_queue<node>q;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            dis[i][j] = INF;
        }
    q.push({x1,y1,0});
    dis[x1][y1] = 0;
    while(!q.empty()){
        node top = q.top();
        q.pop();
        if(vis[top.x][top.y])continue;
        vis[top.x][top.y] = 1;
        for(int k=1;k<=4;k++){
            int nx = top.x + dx[k];
            int ny = top.y + dy[k];
            if(nx < 1 || nx > n || ny < 1 || ny > m)continue;
            if(b[nx][ny] == '#')continue;
            if(vis[nx][ny])continue;
            int nt = max(a[nx][ny]+1,top.t + 1);
            if(nt < dis[nx][ny]){
                dis[nx][ny] = nt;
                q.push({nx,ny,nt});
            }
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(dis[i][j] == INF)continue;
            // cerr<<dis[i][j]<<"\n";
            ans += dis[i][j] * dis[i][j];
        }
    cout<<ans;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

詳細信息

answer.code:12:23: error: narrowing conversion of ‘-1’ from ‘int’ to ‘long long unsigned int’ [-Wnarrowing]
   12 | const int dx[] = {0,1,-1,0,0};
      |                       ^~
answer.code:13:27: error: narrowing conversion of ‘-1’ from ‘int’ to ‘long long unsigned int’ [-Wnarrowing]
   13 | const int dy[] = {0,0,0,1,-1};
      |                           ^~