# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
749166 | nonono | Tracks in the Snow (BOI13_tracks) | C++14 | 569 ms | 34660 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
const int mxN = 4e3 + 10;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int n, m;
char a[mxN][mxN];
bool mark[mxN][mxN];
bool inside(int x, int y){
return (x >= 1) && (x <= n) && (y >= 1) && (y <= m);
}
signed main(){
#define name "test"
if(fopen(name".inp", "r")){
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
cin >> a[i][j];
}
}
if(a[1][1] == '.'){
cout << 0 << "\n";
return 0;
}
memset(mark, false, sizeof(mark));
int res = 1;
queue<pair<int, int>> qu;
qu.push({1, 1});
mark[1][1] = true;
while(!qu.empty()){
pair<int, int> c = qu.front();
qu.pop();
for(int i = 0; i < 4; i ++){
int x = c.first + dx[i];
int y = c.second + dy[i];
if(inside(x, y) && a[x][y] == a[c.first][c.second] && !mark[x][y]){
qu.push({x, y});
mark[x][y] = true;
}
}
}
bool check = true, Check = true;
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
if(mark[i][j]) continue ;
if(a[i][j] == 'F'){
res += check;
check = false;
}
if(a[i][j] == 'R'){
res += Check;
Check = false;
}
}
}
cout << res << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |