답안 #786932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
786932 2023-07-18T15:01:15 Z MCi Tracks in the Snow (BOI13_tracks) C++14
1.66667 / 100
676 ms 357896 KB
#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()
int n, m, a[4005][4005];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int 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;
}

Compilation message

tracks.cpp: In function 'void run_with_file()':
tracks.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(file".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen(file".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 3264 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 1 ms 468 KB Output isn't correct
4 Incorrect 3 ms 2896 KB Output isn't correct
5 Incorrect 3 ms 2388 KB Output isn't correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 1 ms 468 KB Output isn't correct
8 Incorrect 1 ms 596 KB Output isn't correct
9 Correct 1 ms 852 KB Output is correct
10 Incorrect 3 ms 1712 KB Output isn't correct
11 Incorrect 1 ms 1236 KB Output isn't correct
12 Incorrect 2 ms 1876 KB Output isn't correct
13 Incorrect 3 ms 2352 KB Output isn't correct
14 Incorrect 3 ms 2388 KB Output isn't correct
15 Incorrect 5 ms 3412 KB Output isn't correct
16 Incorrect 4 ms 3224 KB Output isn't correct
17 Incorrect 6 ms 3796 KB Output isn't correct
18 Incorrect 3 ms 3028 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 16084 KB Output isn't correct
2 Incorrect 28 ms 12364 KB Output isn't correct
3 Incorrect 304 ms 74420 KB Output isn't correct
4 Incorrect 89 ms 33712 KB Output isn't correct
5 Incorrect 146 ms 48364 KB Output isn't correct
6 Incorrect 164 ms 63260 KB Output isn't correct
7 Incorrect 10 ms 16852 KB Output isn't correct
8 Incorrect 8 ms 16084 KB Output isn't correct
9 Incorrect 2 ms 852 KB Output isn't correct
10 Incorrect 2 ms 1748 KB Output isn't correct
11 Incorrect 8 ms 16852 KB Output isn't correct
12 Incorrect 1 ms 980 KB Output isn't correct
13 Incorrect 28 ms 12396 KB Output isn't correct
14 Incorrect 18 ms 8356 KB Output isn't correct
15 Incorrect 37 ms 26420 KB Output isn't correct
16 Incorrect 11 ms 5228 KB Output isn't correct
17 Incorrect 71 ms 26372 KB Output isn't correct
18 Incorrect 154 ms 85560 KB Output isn't correct
19 Incorrect 91 ms 33636 KB Output isn't correct
20 Incorrect 69 ms 25492 KB Output isn't correct
21 Incorrect 203 ms 56608 KB Output isn't correct
22 Incorrect 137 ms 48204 KB Output isn't correct
23 Incorrect 131 ms 42316 KB Output isn't correct
24 Incorrect 157 ms 49596 KB Output isn't correct
25 Incorrect 676 ms 357896 KB Output isn't correct
26 Incorrect 144 ms 57600 KB Output isn't correct
27 Incorrect 170 ms 65388 KB Output isn't correct
28 Incorrect 169 ms 65340 KB Output isn't correct
29 Incorrect 167 ms 65392 KB Output isn't correct
30 Incorrect 176 ms 64096 KB Output isn't correct
31 Incorrect 117 ms 52856 KB Output isn't correct
32 Incorrect 207 ms 73804 KB Output isn't correct