Submission #1279534

#TimeUsernameProblemLanguageResultExecution timeMemory
1279534enxiayyNautilus (BOI19_nautilus)C++20
100 / 100
97 ms580 KiB
#include <bits/stdc++.h> using namespace std; #define REP(i, l, r) for(int i = (l); i < (r); ++i) #define FOR(i, l, r) for(int i = (l); i <= (r); ++i) #define FORD(i, r, l) for(int i = (r); i >= (l); --i) #define ff first #define ss second #define eb emplace_back #define pb push_back #define all(x) x.begin(), x.end() #define sz(v) (int)v.size() #define compact(v) v.erase(unique(all(v)), v.end()) #define dbg(v) "[" #v " = " << (v) << "]" #define el "\n" using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using pil = pair<int, ll>; using pli = pair<ll, int>; template<class T> bool minimize(T& a, const T& b){ if(a > b) return a = b, true; return false; } template<class T> bool maximize(T& a, const T& b){ if(a < b) return a = b, true; return false; } mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); long long randRange(long long l, long long r){ return uniform_int_distribution<long long>(l,r)(rng); } const int N = 501; int n, m, k; bitset<N> a[2][N], b[N]; string s; void solve() { cin >> n >> m >> k; FOR(i, 1, n) { FOR(j, 1, m) { char c; cin >> c; a[0][i][j] = (c == '.' ? 1 : 0); } b[i] = a[0][i]; } string op; cin >> op; for (auto t : op) { if (t == 'N') { FOR(i, 1, n) a[1][i] = a[0][i + 1] & b[i]; } else if (t == 'S') { FOR(i, 1, n) a[1][i] = a[0][i - 1] & b[i]; } else if (t == 'E') { FOR(i, 1, n) a[1][i] = (a[0][i] << 1) & b[i]; } else if (t == 'W') { FOR(i, 1, n) a[1][i] = (a[0][i] >> 1) & b[i]; } else { FOR(i, 1, n) a[1][i] = (a[0][i + 1] | a[0][i - 1] | (a[0][i] >> 1) | (a[0][i] << 1)) & b[i]; } FOR(i, 1, n) a[0][i] = a[1][i]; // cout << el; // FOR(i, 1, n) cout << a[0][i] << el; // cout << el; } ll ans = 0; FOR(i, 1, n) ans += a[0][i].count(); cout << ans << el; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); #define task "task" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } solve(); return 0; } /* */

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:84:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:85:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...