QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#696470#8236. Snake MoveGLLF234WA 6ms77284kbC++201.8kb2024-10-31 22:46:402024-10-31 22:46:41

Judging History

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

  • [2024-10-31 22:46:41]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:77284kb
  • [2024-10-31 22:46:40]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define PII pair<int,int>
#define ull unsigned long long
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};
bool vis[3003][3003];
int n,m,k;
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(vis[a][b]) continue;
            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});
                    vis[a][b]=1;
                }
            }
        }
    }
}
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();
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 77284kb

input:

4 5 5
3 5
3 4
3 3
3 2
4 2
.....
.....
.....
.....

output:

710

result:

wrong answer 1st lines differ - expected: '293', found: '710'