Submission #1240249

#TimeUsernameProblemLanguageResultExecution timeMemory
1240249sitingfakeNautilus (BOI19_nautilus)C++20
0 / 100
0 ms324 KiB
#include<bits/stdc++.h> using namespace std; // define #define execute cerr << " Time: " << fixed << setprecision(6) << (1.0 * clock() / CLOCKS_PER_SEC) << "s\n"; #define ll long long #define ld double #define ii pair<int,int> #define se second #define fi first #define iii pair<int,ii> #define all(v) v.begin(),v.end() #define bit(x,i) (((x)>>(i))&1LL) #define flip(x,i) ((x)^(1LL<<(i))) #define ms(d,x) memset(d,x,sizeof(d)) #define sitingfake 1 #define orz 1 #define exist __exist #define ends __ends #define visit visited #define left __left #define right __right //constant const ll mod = 1e9 + 7; const long long linf = 4557430888798830399; const int inf = 1061109567; const int maxarr = 1e6 + 5; int dx[] = {0 , -1 , 0 , 1}; int dy[] = {-1 , 0 , 1 , 0}; template<typename T> bool maximize(T &a, const T &b) { if(a < b) {a = b; return 1;} return 0; } template<typename T> bool minimize(T &a, const T &b) { if(a > b) {a = b; return 1;} return 0; } inline void Plus(ll & a ,ll b) { b %= mod; a += b; if(a >= mod) a -= mod; if(a < 0) a += mod; return; } inline void Mul(ll & a, ll b) { a %= mod; b %= mod; a *= b; a %= mod; return; } //code const int maxn = 505; int n , m , q; char a[maxn][maxn]; string s; bitset <501> row[2][505]; bitset <501> r[505]; void ProcessW(int cur , int pre , bool f) { if(!f) { for(int i = 1; i <= n; i++) { row[cur][i] = (row[pre][i] << 1) & r[i]; } } else { for(int i = 1; i <= n; i++) { row[cur][i] |= (row[pre][i] << 1) & r[i]; } } } void ProcessE(int cur , int pre , bool f) { for(int i = 1; i <= n; i++) { row[cur][i] = (row[pre][i] >> 1) & r[i]; } } void ProcessS(int cur , int pre , bool f) { if(!f) { for(int i = 2; i <= n; i++) { row[cur][i] = row[pre][i - 1] & r[i]; } row[cur][1].reset(); } else { for(int i = 2; i <= n; i++) { row[cur][i] |= (row[pre][i - 1] & r[i]); } } } void ProcessN(int cur , int pre , bool f) { if(!f) { for(int i = n - 1; i >= 1; i--) { row[cur][i] = row[pre][i + 1] & r[i]; } row[cur][n].reset(); } else { for(int i = n - 1; i >= 1; i--) { row[cur][i] |= (row[pre][i + 1] & r[i]); } } } void solve(void) { cin >> n >> m >> q; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cin >> a[i][j]; if(a[i][j] == '.') { r[i].set(j); } } } cin >> s; s = ' ' + s; for(int i = 1; i <= n; i++) { row[0][i] = r[i]; } for(int i = 1; i <= q; i++) { int cur = i & 1; int pre = !cur; if(s[i] == 'W') { ProcessW(cur , pre , 0); } else if(s[i] == 'E') { ProcessE(cur , pre , 0); } else if(s[i] == 'N') { ProcessN(cur , pre , 0); } else if(s[i] == 'S') { ProcessS(cur , pre , 0); } else { ProcessE(cur , pre , 1); ProcessN(cur , pre , 1); ProcessS(cur , pre , 1); ProcessW(cur , pre , 1); } } int ans = 0; for(int i = 1; i <= n; i++) { ans += row[q & 1][i].count(); } cout << ans; } /** 5 9 7 ...##.... ..#.##..# ..#....## .##...#.. ....#.... WS?EE?? **/ signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "" if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } int tc; tc = 1; while(tc--) solve(); //execute; }

Compilation message (stderr)

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