Submission #1137310

#TimeUsernameProblemLanguageResultExecution timeMemory
1137310henrllyTracks in the Snow (BOI13_tracks)C++20
2.19 / 100
1605 ms830312 KiB
// time-limit: 3000 #include <bits/stdc++.h> #include <vector> using namespace std; #define ll long long using vll = vector<ll>; using vvll = vector<vector<ll> >; using mpll = map<pair<ll, ll>, ll>; using pll = pair<ll, ll>; using vi = vector<int>; using vvi = vector<vector<int> >; using pi = pair<int, int>; void setIO(string name = "") { if (name.size()) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } void solve() { return; } int visited[4001][4001]; char m[4001][4001]; int xx, yy; int h, w; bool findn(int x, int y) { if (x < 0 || y < 0 || x >= w || y >= h) return false; if (m[y][x] == '.' || visited[y][x]) return false; visited[y][x] = 1; if (m[y][x] == 'F' || m[y][x] == 'R') { xx = x; yy = y; return true; } return findn(x-1, y) || findn(x+1, y) || findn(x, y-1) || findn(x, y+1); } char cur; void cover(int x, int y) { if (x < 0 || y < 0 || x >= w || y >= h) return; if (m[y][x] == '.' || visited[y][x]) return; visited[y][x] = 1; if (m[y][x] == cur) m[y][x] = 'C'; cover(x-1, y); cover(x+1, y); cover(x, y-1); cover(x, y+1); } int main() { ios::sync_with_stdio(false); cin.tie(0); // setIO("test"); cin >> h >> w; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> m[i][j]; } } ll res = 0; // "expand" from 0,0 until F or R reached while (true) { memset(visited, 0, sizeof(visited)); xx = -1; yy = -1; if (!findn(0,0)) break; cur = m[yy][xx]; memset(visited, 0, sizeof(visited)); cover(xx,yy); res++; } cout << res << endl; return 0; }

Compilation message (stderr)

tracks.cpp: In function 'void setIO(std::string)':
tracks.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...