| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 747281 | Trunkty | Zoo (COCI19_zoo) | C++14 | 1 ms | 224 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
const int MAXL = 1005;
int h,w;
char track[MAXL][MAXL];
bool check[MAXL][MAXL];
vector<pair<int,int>> p={{1,1}},p2;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> h >> w;
for(int i=1;i<=h;i++){
string a;
cin >> a;
for(int j=0;j<w;j++){
track[i][j+1] = a[j];
}
}
char st=track[1][1];
check[1][1] = true;
for(int i=0;i<p.size();i++){
int x=p[i].first,y=p[i].second;
if(track[x-1][y]==st and not check[x-1][y]){
p.push_back({x-1,y});
check[x-1][y] = true;
}
if(track[x+1][y]==st and not check[x+1][y]){
p.push_back({x+1,y});
check[x+1][y] = true;
}
if(track[x][y-1]==st and not check[x][y-1]){
p.push_back({x,y-1});
check[x][y-1] = true;
}
if(track[x][y+1]==st and not check[x][y+1]){
p.push_back({x,y+1});
check[x][y+1] = true;
}
}
int cnt=0;
while(p.size()>0){
if(st=='R'){
st = 'F';
}
else{
st = 'R';
}
p2 = {};
for(int i=0;i<p.size();i++){
int x=p[i].first,y=p[i].second;
if(track[x-1][y]==st and not check[x-1][y]){
p2.push_back({x-1,y});
check[x-1][y] = true;
}
if(track[x+1][y]==st and not check[x+1][y]){
p2.push_back({x+1,y});
check[x+1][y] = true;
}
if(track[x][y-1]==st and not check[x][y-1]){
p2.push_back({x,y-1});
check[x][y-1] = true;
}
if(track[x][y+1]==st and not check[x][y+1]){
p2.push_back({x,y+1});
check[x][y+1] = true;
}
}
p = p2;
for(int i=0;i<p.size();i++){
int x=p[i].first,y=p[i].second;
if(track[x-1][y]==st and not check[x-1][y]){
p.push_back({x-1,y});
check[x-1][y] = true;
}
if(track[x+1][y]==st and not check[x+1][y]){
p.push_back({x+1,y});
check[x+1][y] = true;
}
if(track[x][y-1]==st and not check[x][y-1]){
p.push_back({x,y-1});
check[x][y-1] = true;
}
if(track[x][y+1]==st and not check[x][y+1]){
p.push_back({x,y+1});
check[x][y+1] = true;
}
}
cnt++;
}
cout << cnt;
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
