Submission #16841

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
168412015-10-16 10:43:40kdh9949Portals (BOI14_portals)C++98
70 / 100
1000 ms40568 KiB
#include <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;
struct mindol{int x,y,t;bool operator<(const mindol &a)const{return t>a.t;}};
priority_queue<mindol> pq;
char m[1010][1010];
int dt[4][1010][1010],dist[1010][1010];
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
int w,h,gx,gy,flag;
int main(){
scanf("%d%d",&w,&h);
for(int i=1;i<=w;i++){
scanf("%s",m[i]+1);
}
for(int i=0;i<=w+1;i++)for(int j=0;j<4;j++)m[i][0]=m[i][h+1]='#',dt[j][i][0]=dt[j][i][h+1]=-1;
for(int i=0;i<=h+1;i++)for(int j=0;j<4;j++)m[0][i]=m[w+1][i]='#',dt[j][0][i]=dt[j][w+1][i]=-1;
for(int i=1;i<=w;i++){
for(int j=1;j<=h;j++){
dist[i][j]=987654321;
if(m[i][j]=='S')pq.push({i,j,0});
if(m[i][j]=='C')gx=i,gy=j;
dt[0][w+1-i][j]=( m[w+1-i][j]=='#' ? -1 :dt[0][w+2-i][j]+1);
dt[1][i][j]=(m[i][j]=='#' ? -1 : dt[1][i-1][j]+1);
dt[2][i][h+1-j]=(m[i][h+1-j]=='#' ? -1 : dt[2][i][h+2-j]+1);
dt[3][i][j]=(m[i][j]=='#' ? -1 : dt[3][i][j-1]+1);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...