답안 #84856

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
84856 2018-11-17T13:45:15 Z sjhuang26 Tracks in the Snow (BOI13_tracks) C++17
38.75 / 100
90 ms 38568 KB
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef pair<int,int>ii;
queue<ii>q[2];
int R,C,K=0,res=0;
bool s;
string d[500];
const string fr="FR";
int main(){
	cin>>R>>C;
	q[0]=queue<ii>();
	q[1]=queue<ii>();
	for(int i=0;i<R;++i){
		cin>>ws;
		cin>>d[i];
		for(int j=0;j<C;++j)if(d[i][j]=='.')++K;
	}
	s=d[0][0]==fr[1];
	d[0][0]='.';
	q[s].push({0,0});
	while(K<R*C){
		//cout<<"---"<<K<<endl;
		++res;
		q[!s]=queue<ii>();
		while(!q[s].empty()){
			++K;
			//cout<<"IT"<<endl;
			ii rw=q[s].front();
			int x=rw.first,y=rw.second;
			//cout<<q[s].size()<<' '<<x<<' '<<y<<endl;
			q[s].pop();
			if(0<x&&d[x-1][y]!='.'){
				q[d[x-1][y]==fr[1]].push({x-1,y});
				d[x-1][y]='.';
			}
			if(x<R-1&&d[x+1][y]!='.'){
				q[d[x+1][y]==fr[1]].push({x+1,y});
				d[x+1][y]='.';
			}
			if(0<y&&d[x][y-1]!='.'){
				q[d[x][y-1]==fr[1]].push({x,y-1});
				d[x][y-1]='.';
			}
			if(y<C-1&&d[x][y+1]!='.'){
				q[d[x][y+1]==fr[1]].push({x,y+1});
				d[x][y+1]='.';
			}
		}
		s=!s;
	}
	cout<<res<<'\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1120 KB Output is correct
2 Correct 18 ms 1120 KB Output is correct
3 Correct 2 ms 1120 KB Output is correct
4 Correct 12 ms 1344 KB Output is correct
5 Correct 6 ms 1344 KB Output is correct
6 Correct 2 ms 1344 KB Output is correct
7 Correct 2 ms 1344 KB Output is correct
8 Correct 2 ms 1344 KB Output is correct
9 Correct 3 ms 1348 KB Output is correct
10 Correct 6 ms 1488 KB Output is correct
11 Correct 5 ms 1568 KB Output is correct
12 Correct 9 ms 1736 KB Output is correct
13 Correct 6 ms 1736 KB Output is correct
14 Correct 6 ms 1796 KB Output is correct
15 Correct 18 ms 2392 KB Output is correct
16 Correct 19 ms 2768 KB Output is correct
17 Correct 16 ms 2876 KB Output is correct
18 Correct 12 ms 2988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 26 ms 5364 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 80 ms 13156 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 42 ms 13156 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 62 ms 13156 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 78 ms 18140 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 3 ms 18140 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 18140 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Correct 5 ms 18140 KB Output is correct
10 Correct 4 ms 18140 KB Output is correct
11 Runtime error 3 ms 18140 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Correct 4 ms 18140 KB Output is correct
13 Runtime error 27 ms 18140 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 22 ms 18140 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 22 ms 18140 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Correct 38 ms 18140 KB Output is correct
17 Runtime error 65 ms 18492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 44 ms 19628 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 42 ms 20764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 58 ms 21900 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 59 ms 23564 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 58 ms 25264 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 60 ms 26900 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 59 ms 28732 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 81 ms 34544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 67 ms 34552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 90 ms 38560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 77 ms 38560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 79 ms 38568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 79 ms 38568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 63 ms 38568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 77 ms 38568 KB Execution killed with signal 11 (could be triggered by violating memory limits)