Submission #1157106

#TimeUsernameProblemLanguageResultExecution timeMemory
1157106baolam1202Nautilus (BOI19_nautilus)C++20
0 / 100
0 ms320 KiB
// Author: Wu Bao Lin #include <bits/stdc++.h> #define ll long long #define umv unordered_map #define li long int #define el "\n" #define lli long long int #define ull unsigned long long #define ulli unsigned long long int #define ld long double #define fi first #define se second #define pb push_back #define eb emplace_back #define pp pop_back #define inverse greater<ll> #define ins insert #define le length #define left(idx) (idx << 1) #define right(idx) ((idx << 1)+1) #define all(x) x.begin(),x.end() #define MASK(i) (1ll << i) #define MAXINT INT_MAX #define str stringstream #define freo(s) freopen(s".INP","r",stdin); freopen(s".OUT","w",stdout); #define all(x) x.begin(),x.end() #define pir pair<int,int> #define ci(n,m) cin >> n >> m; #define fx(a,n) a,a+n #define checkmatrix(a,n,m) for(int ix = 1;ix <= n;ix++){for(int jx = 1;jx <= m;jx++) cout << a[ix][jx] << " "; cout << el;} #define checkarray(a,n) for(int ix = 1;ix <= n;ix++) cout << a[ix] << " "; #define checkvector(a) for(int ix = 0;ix < a.size();ix++) cout << a[ix] << " "; #define runtime cerr<< "Time elapsed: " << (1.0*clock()/CLOCKS_PER_SEC)<< "s" << el; #define base 311 #define pii pair<int,pair<int,int>> using namespace std; const ll mod = 1e9+7; const ll ME = 1e4+100; const ll modx = 998244353; const int module = 5e6 + 11; const ll MM = 1e3+1; const ll MAXLL = LLONG_MAX; const ll NMAXLL = -MAXLL; const char dir[4] = {'U','D','L','R'}; const int dx[4] = {1, -1, 0, 0}; const int dy[4] = {0, 0, 1, -1}; bitset<505> mask[505]; vector<bitset<505>> q; int n = 0,m = 0,k = 0; char a[505][505] = {}; bitset<505> trash = {}; void _LoserDuck_(){ cin >> n >> m >> k; for(int i = 0;i < n;i++){ for(int j = 0;j < m;j++){ cin >> a[i][j]; if (a[i][j] == '.') mask[i][j] = 1; } } for(int i = 0;i < n;i++){ q.push_back(mask[i]); } while(k--){ char s; cin >> s; if (s == 'w') for(int i = 0;i < n;i++) q[i] = (q[i] >> 1) & mask[i]; else if (s == 'E') for(int i = 0;i < n;i++) q[i] = (q[i] << 1) & mask[i]; else if (s == 'N'){ for(int i = 0;i < n-1;i++) q[i] = q[i+1] & mask[i]; q[n-1] = trash; } else if (s == 'S'){ for(int i = n-1;i >= 1;i--) q[i] = q[i-1] & mask[i]; q[0] = trash; } else if (s == '?'){ vector<bitset<505>> curr; for(int i = 0;i < n;i++){ bitset<505> x = {}; curr.push_back(x); } for(int i = 0;i < n;i++) curr[i] |= (q[i] >> 1) & mask[i]; for(int i = 0;i < n;i++) curr[i] |= (q[i] << 1) & mask[i]; for(int i = 0;i < n-1;i++) curr[i] |= q[i+1] & mask[i]; for(int i = 1;i < n;i++) curr[i] |= q[i-1] & mask[i]; q = curr; } } int ans = 0; for(bitset<505> id: q) ans += id.count(); cout << ans; return; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; int sub = 0; //cin >> t; while(t--){ _LoserDuck_(); } runtime; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...