| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1136690 | Richard_Dyinman | Tracks in the Snow (BOI13_tracks) | C++20 | 2 ms | 328 KiB | 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define file \
  freopen("guard.in", "r", stdin);\
  freopen("guard.out", "w", stdout)
#define OJudge(in,out) \
      freopen(in, "r", stdin);\
      freopen(out, "w", stdout)
#define FIn   \
  cin.tie(0); \
  cout.tie(0); \
  ios_base::sync_with_stdio(false)
const string IN = "input.txt";
const string OUT = "output.txt";
int  tc;
ll n,m,a,b,c,k;
char arr[4100][4100];
int fin[4100][4100];
int cnt = 0;
void dfs(int x, int y , char cur){
    if(!fin[x][y] && arr[x][y] != cur)
        return;
    if(fin[x][y] == cnt)
        return;
    fin[x][y] = cnt;
    if(x > 0){
        dfs(x - 1, y , cur);
    }
    if(x < n - 1){
        dfs(x + 1, y , cur);
    }
    if(y > 0){
        dfs(x , y - 1 , cur);
    }
    if(y < m-1){
        dfs(x , y +1, cur);
    }
}
void solve() {
    cin>>n>>m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin>>arr[i][j];
            fin[i][j] = 0;
        }
    }
    for(int i = 0; i<n; i++){
        for(int j = 0; j < m; j++){
            if(arr[i][j] != '.' && !fin[i][j]){
                cnt++;
                dfs(i, j, arr[i][j]);
            }
        }
    }
    cout<<cnt;
}
int main() {
    FIn;
    //file;
#ifndef ONLINE_JUDGE
    OJudge(IN.c_str(),OUT.c_str());
#endif
    bool test = 0;
    if (test)
        cin>>tc;
    else tc = 1;
    for (int i = 1; i<=tc; i++){
        solve();
    }
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
