Submission #171885


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<queue>
using namespace std;

typedef pair<int,int> P;

int data[1001][1001];
int map_d[1001][1001];
int D;
int W,H;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};


int bfs(){
	queue<P> que;
	map_d[0][0]=0;
	
	que.push(P(0,0));
	
	int ans=0;
	
	while(que.size()){
		P p=que.front();que.pop();
		for(int i=0;i<4;i++){
			int ny=p.first+dy[i],nx=p.second+dx[i];
			if(0<=nx && nx<W && 0<=ny && ny<H && map_d[p.first][p.second]+1<=D){
				map_d[ny][nx]=map_d[p.first][p.second]+1;
				if(map_d[ny][nx]==D){
				ans=max(ans,data[ny][nx]);
				}else{
				que.push(P(ny,nx));
				
				}
			}
		}
		
		for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
		cout<<map_d[i][j];
		}
		cout<<endl;
		}
	}
return ans;
}

int main(){
cin>>H>>W>>D;

for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	cin>>data[i][j];
	}
}

cout<<bfs()<<endl;
}

Submission Info

Submission Time
Task B - 謎の人物X
User kamui
Language C++ (G++ 4.6.4)
Score 0
Code Size 984 Byte
Status WA
Exec Time 2034 ms
Memory 26652 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 0 / 60 0 / 40
Status
WA × 2
TLE × 1
WA × 3
TLE × 15
WA × 1
TLE × 29
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt
Subtask2 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt
Case Name Status Exec Time Memory
sample_01.txt WA 22 ms 736 KB
sample_02.txt TLE 2029 ms 7204 KB
sample_03.txt WA 22 ms 928 KB
subtask1_01.txt WA 21 ms 928 KB
subtask1_02.txt TLE 2029 ms 21672 KB
subtask1_03.txt TLE 2029 ms 2912 KB
subtask1_04.txt TLE 2029 ms 18332 KB
subtask1_05.txt TLE 2029 ms 18860 KB
subtask1_06.txt TLE 2029 ms 15720 KB
subtask1_07.txt TLE 2030 ms 17268 KB
subtask1_08.txt TLE 2029 ms 19120 KB
subtask1_09.txt TLE 2029 ms 18980 KB
subtask1_10.txt TLE 2029 ms 18416 KB
subtask1_11.txt TLE 2029 ms 18980 KB
subtask1_12.txt TLE 2029 ms 18472 KB
subtask1_13.txt TLE 2030 ms 19060 KB
subtask1_14.txt TLE 2029 ms 18468 KB
subtask1_15.txt TLE 2028 ms 18860 KB
subtask2_01.txt TLE 2034 ms 26652 KB
subtask2_02.txt TLE 2030 ms 6312 KB
subtask2_03.txt TLE 2029 ms 25496 KB
subtask2_04.txt TLE 2028 ms 25124 KB
subtask2_05.txt TLE 2030 ms 24868 KB
subtask2_06.txt TLE 2029 ms 25884 KB
subtask2_07.txt TLE 2031 ms 26288 KB
subtask2_08.txt TLE 2031 ms 24100 KB
subtask2_09.txt TLE 2030 ms 25240 KB
subtask2_10.txt TLE 2031 ms 25632 KB
subtask2_11.txt TLE 2029 ms 26152 KB
subtask2_12.txt TLE 2030 ms 25508 KB
subtask2_13.txt TLE 2031 ms 25820 KB
subtask2_14.txt TLE 2030 ms 25892 KB
subtask2_15.txt TLE 2030 ms 25752 KB