Submission #1187116

#TimeUsernameProblemLanguageResultExecution timeMemory
1187116vux2codeTracks in the Snow (BOI13_tracks)C++20
2.19 / 100
691 ms795000 KiB
// Src : Vux2Code /* Note : */ #include <bits/stdc++.h> #define fi first #define se second #define pusb push_back #define popb pop_back #define pusf push_front #define popf pop_front using namespace std; // template <typename T> void vout(T s){ cout << s << endl; exit(0);} typedef long long ll; typedef long double ld; typedef pair <ll, ll> pll; const ll maxN = 4e3 + 5, maxLog = 20, inf64 = 1e18, inf32 = 1e9, mod = 1e9 + 7; void maxi (ll &x, ll y) {x = max (x, y);} void mini (ll &x, ll y) {x = min (x, y);} /* ---------HASHING-------- */ // const base = 31, mod2 = 1e9 + 9; /* ---------BITMASK-------- */ // ll count (ll x) {return __builtin_popcountll (x);} // ll fst (ll x) {return 63 - __builtin_clzll (x);} // ll last (ll x) {return __builtin_ctzll (x);} // bool bit (ll x, ll y) {return ((x >> y) & 1);} pll adj [] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; ll t = 1; ll n, m, cnt, cntF, cntR; char a [maxN] [maxN]; bool ck [maxN] [maxN]; void dfs (pll x) { ck [x. fi] [x. se] = 1; cnt ++; for (pll i : adj) { pll nx = {x. fi + i. fi, x. se + i. se}; if (a [1] [1] != a [nx. fi] [nx. se] || ck [nx. fi] [nx. se]) continue; dfs (nx); } } void solve () { cin >> n >> m; for (int i = 1; i <= n; i ++) { for (int j = 1; j <= m; j ++) { cin >> a [i] [j]; if (a [i] [j] == 'F') cntF ++; else if (a [i] [j] == 'R') cntR ++; } } ll ans = (cntF > 0) + (cntR > 0); dfs ({1, 1}); ans += (a [1] [1] == 'F' ? (cnt < cntF) : (cnt < cntR)); cout << ans; } int main () { ios::sync_with_stdio (0); cin.tie (0); cout.tie (0); // #define TASK "E:/Code/CP/task" // if (fopen (TASK".inp", "r")) { // freopen (TASK".inp", "r", stdin); // freopen (TASK".out", "w", stdout); // } //cin >> t; while (t--) solve (); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...