Submission #786932

#TimeUsernameProblemLanguageResultExecution timeMemory
786932MCiTracks in the Snow (BOI13_tracks)C++14
1.67 / 100
676 ms357896 KiB
#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 (stderr)

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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...