QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#696443#8236. Snake MoveGLLF234Compile Error//C++201.7kb2024-10-31 22:37:302024-10-31 22:37:31

Judging History

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

  • [2024-10-31 22:37:31]
  • 评测
  • [2024-10-31 22:37:30]
  • 提交

answer

#include<bits/stdc++.h>
// #define int long long
#define int unsigned long long
#define PII pair<int,int>
using ll=long long;
using namespace std;
double a[100005];
int mp[3003][3003];
int dis[3003][3003];
// bool vis[3003][3003];
// int dis2[3003][3003];
const int inf=0x7f7f7f7f7f7f7f7f;
int xx[5]={0,0,0,1,-1};
int yy[5]={0,1,-1,0,0};
int n,m,k;
#define ull unsigned long long
void bfs(int x,int y){
    queue<PII> q;
    q.push({x,y});
    dis[x][y]=0;
    // vis[x][y]=1;
    while(!q.empty()){
        auto it=q.front();
        q.pop();
        for(int i=1;i<=4;i++){
            int a=it.first+xx[i],b=it.second+yy[i];
            if(a<=n&&a>0&&b<=m&&b>0&&mp[a][b]!=inf){
                if(dis[a][b]>max(mp[a][b],dis[it.first][it.second]+1)){
                    dis[a][b]=max(mp[a][b],dis[it.first][it.second]+1);
                    q.push({a,b});
                }
            }
        }
    }
}
void slove(){
    memset(dis,0x7f,sizeof(dis));
    // memset(dis2,0x7f,sizeof(dis2));
    cin>>n>>m>>k;
    int sx,sy;
    for(int i=1;i<=k;i++){
        int u,v;
        cin>>u>>v;
        mp[u][v]=k-i+1;
        if(i==1) sx=u,sy=v;
    }
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        for(int j=0;j<m;j++){
            if(s[j]=='#') mp[i][j+1]=inf;
        }
    }
    bfs(sx,sy);
    // bfs2(sx,sy);
    ull ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(dis[i][j]==0x7f7f7f7f7f7f7f7f) continue;
            // cout<<dis[i][j]<<endl;
            ans=ans+dis[i][j]*dis[i][j];
        }
    }
    cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T=1;
    // cin>>T;
    while(T--){
        slove();
    }
}

Details

answer.code:13:20: error: narrowing conversion of ‘-1’ from ‘int’ to ‘long long unsigned int’ [-Wnarrowing]
   13 | int xx[5]={0,0,0,1,-1};
      |                    ^~
answer.code:14:16: error: narrowing conversion of ‘-1’ from ‘int’ to ‘long long unsigned int’ [-Wnarrowing]
   14 | int yy[5]={0,1,-1,0,0};
      |                ^~