제출 #786930

#제출 시각아이디문제언어결과실행 시간메모리
786930MCiTracks in the Snow (BOI13_tracks)C++14
1.67 / 100
827 ms436396 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() 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) 메시지

tracks.cpp: In function 'void run_with_file()':
tracks.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(file".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen(file".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...