# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
786930 | MCi | Tracks in the Snow (BOI13_tracks) | C++14 | 827 ms | 436396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define file "D:\\CWistor\\code"
using namespace std;
#define ll long long
#define MAX 100100
#define fi first
#define se second
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<long long>
#define mem(a, b) memset((a), (b), sizeof((a)))
#define all(c) (c).begin(), (c).end()
const int MOD = 1e9 + 7;
const int N = 2e6 + 6;
const ll M = (ll)1e18 + 7LL;
const int INF = 1e9 + 7;
ll oo = 1e17 + 5;
ll n, m, a[5005][5005];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
ll cnt = 0;
void run_with_file()
{
if (fopen(file".inp", "r"))
{
freopen(file".inp", "r", stdin);
freopen(file".out", "w", stdout);
}
}
void inp(){
cin >> n >> m;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
char x;
cin >> x;
if(x == '.') a[i][j] = 1;
else a[i][j] = 0;
}
}
}
void dfs(int i, int j){
a[i][j] = 0;
for(int k = 0; k < 4; ++k){
int i1 = i + dx[k];
int j1 = j + dy[k];
if(i1 >= 1 && i1 <= n && j1 >= 1 && j1 <= m && a[i1][j1] == 1){
a[i1][j1] = 0;
dfs(i1, j1);
}
}
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
run_with_file();
inp();
if(n == 1 && m == 1){
if(a[n][m] == 1) cout << 1;
else cout << 0;
exit(0);
}
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
if(a[i][j] == 1){
cnt++;
dfs(i, j);
}
}
}
cout << cnt;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |