Submission #679604

#TimeUsernameProblemLanguageResultExecution timeMemory
679604peijarNautilus (BOI19_nautilus)C++17
100 / 100
181 ms416 KiB
#include <bits/stdc++.h> #define int long long using namespace std; namespace std { template <typename T> ostream &operator<<(ostream &out, const vector<T> &vec) { out << "["; for (int i = 0; i < (int)vec.size(); ++i) { out << vec[i]; if (i + 1 < (int)vec.size()) out << ", "; } return out << "]"; } } // namespace std void dbg_out() { cout << endl; } template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); } #ifdef DEBUG #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif const int MAXN = 500; signed main(void) { ios_base::sync_with_stdio(false); cin.tie(0); int nbLig, nbCol, nbOp; cin >> nbLig >> nbCol >> nbOp; vector<bitset<MAXN>> canUse(nbLig); for (int lig = 0; lig < nbLig; ++lig) for (int col = 0; col < nbCol; ++col) { char c; cin >> c; if (c == '.') canUse[lig][col] = 1; } vector<bitset<MAXN>> curPossible(nbLig); for (int lig = 0; lig < nbLig; ++lig) curPossible[lig] = canUse[lig]; string s; cin >> s; for (char c : s) { vector<bitset<MAXN>> nxtPossible(nbLig); if (c == 'N' or c == '?') { for (int lig = 0; lig + 1 < nbLig; ++lig) nxtPossible[lig] |= curPossible[lig + 1]; } if (c == 'S' or c == '?') { for (int lig = 1; lig < nbLig; ++lig) nxtPossible[lig] |= curPossible[lig - 1]; } if (c == 'W' or c == '?') { for (int lig = 0; lig < nbLig; ++lig) nxtPossible[lig] |= curPossible[lig] >> 1; } if (c == 'E' or c == '?') { for (int lig = 0; lig < nbLig; ++lig) nxtPossible[lig] |= curPossible[lig] << 1; } for (int lig = 0; lig < nbLig; ++lig) curPossible[lig] = nxtPossible[lig] & canUse[lig]; } int sol = 0; for (int lig = 0; lig < nbLig; ++lig) sol += curPossible[lig].count(); cout << sol << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...