我所有点都是wrong answer On line 1 column 1, read -, expected 7. 得分0。
但是我下载了数据手动输入答案又没有错误,这是为什么呢!!!???
下面是我的代码
#include<bits/stdc++.h>
using namespace std;
struct Mystruct{
int s;
int num;
};
int maps[31][31];
map<int,int> vis;
int n,m,q;
int wx,wy,stx,sty,edx,edy;
queue<Mystruct> a;
Mystruct example;
Mystruct example2;
int ans;
int xx[4]={-1,0,1,0};
int yy[4]={0,1,0,-1};
int terms(int x1,int y1,int x2,int y2){
int transform;
transform+=x1;
transform*=100;
transform+=y1;
transform*=100;
transform+=x2;
transform*=100;
transform+=y2;
return transform;
}
int main(){
scanf("%d%d%d",&n,&m,&q);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
scanf("%d",&maps[i][j]);
for(int t=1;t<=q;t++)
{
int ans=-1;
scanf("%d%d%d%d%d%d",&wx,&wy,&stx,&sty,&edx,&edy);
if(maps[wx][wy]==0||maps[stx][sty]==0||maps[edx][edy]==0)
{
printf("%d",ans);
continue;
}
example2.s=0,example2.num=terms(wx,wy,stx,sty);
a.push(example2);
vis[example2.num]=1;
while(!a.empty())
{
int trans;
int vacantx,vacanty,nowx,nowy;
int nextx,nexty;
int nextnowx,nextnowy;
example=a.front();
a.pop();
trans=example.num;
nowy=trans%100;
trans/=100;
nowx=trans%100;
trans/=100;
vacanty=trans%100;
trans/=100;
vacantx=trans%100;
if(nowx==edx&&nowy==edy)
{
ans=example.s;
break;
}
for(int i=0;i<=3;++i)
{
nextx=vacantx+xx[i],nexty=vacanty+yy[i];
nextnowx=nowx,nextnowy=nowy;
if(nextx<=0||nextx>n||nexty<=0||nexty>m)
continue;
if(maps[nextx][nexty]==0)
continue;
if(nextx==nowx&&nexty==nowy)
nextnowx=vacantx,nextnowy=vacanty;
trans=terms(nextx,nexty,nextnowx,nextnowy);
if(vis[trans]==1)
continue;
else
{
example2.s=example.s+1,example2.num=trans,vis[trans]=1,a.push(example2);
}
}
}
printf("%d\n",ans);
while(!a.empty())
a.pop();
vis.clear();
}
return 0;
}