#include<iostream>
#include<cstdio>
char aa[2001][2001];
int x1,y1,vis[2001][2001];
struct NODE
{
int x,y,step;
}pla[1000001];
int k;
int bfs(int a,int b)
{
NODE loc,next;
loc.x=1,loc.y=1,loc.step=0;
int head=0,tail=0;
pla[tail++]=loc;
vis[1][1]=1;
int nx[4]={1,0,-1,0},
ny[4]={0,1,0,-1};
while(head<tail)
{
loc=pla[head++];
int i;
for( i=0;i<4;i++)
{
int lx=loc.x+nx[i];
int ly=loc.y+ny[i];
if(lx==a&&ly==b)return loc.step+1;
if(lx>0&&lx<=a&&ly>0&&ly<=b&&!vis[lx][ly]&&aa[lx][ly]=='.')
{
next=loc;
next.x=lx;next.y=ly;
next.step++;
pla[tail++]=next;
vis[lx][ly]=1;
}
}
}
}
int main()
{
scanf("%d%d%d",&x1,&y1,&k);
for(int i=1;i<=x1;i++)
{
scanf("%s",&aa[i][1]);
}
// cout<<bfs(x1,y1)<<endl;
int len=bfs(x1,y1);
len=len-(x1+y1-2);
int ucnt=(x1+y1-2)+len/2;//int acnt=(n+m-2)+len/2
int dcnt=len/2;
long long ans=1e6+10;
int cnt=0;
while (k--)
{
long long a,b,t;
scanf("%lld%lld",&a,&b);
t=a*ucnt+b*dcnt;
if (t<ans)
{
ans=t; cnt=1;
}
else if (t==ans)
cnt++;
}
printf("%lld %d\n",ans,cnt);//
return 0;
}
为啥只有20分呀 本zurou不解