Submission #925657

# Submission time Handle Problem Language Result Execution time Memory
925657 2024-02-12T07:00:04 Z vjudge1 Nautilus (BOI19_nautilus) C++17
29 / 100
921 ms 262144 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define emb emplace_back
#define emc emplace
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
template <class type_key, class type_val>
using um = unordered_map<type_key, type_val>;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

int dx[] = {+1,-1,0,0};
int dy[] = {0,0,+1,-1};

signed main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
      
      int n, m, k;
      cin >> n >> m >> k;

      char c[n+1][m+1];
      for( int i = 1; i <= n; i++ ) {
            for( int j = 1; j <= m; j++ ) {
                  cin >> c[i][j];
            }
      }

      char s[k+1];
      for( int i = 1; i <= k; i++ ) {
            cin >> s[i];
      }

      set<pii> ans;
      for( int i = 1; i <= n; i++ ) {
            for( int j = 1; j <= m; j++ ) {
                  if( c[i][j] == '.') {
                        queue<pair<pii, int>> q;
                        q.push({{i,j},1});
                        while( !q.empty() ) {
                              auto [x,y] = q.front().F;
                              int id = q.front().S;
                              q.pop();

                              if( y < 1 || y > m || x < 1 || x > n ) continue;
                              if( c[x][y] == '#') continue;

                              if( id > k ) {
                                    ans.insert({x,y});
                              }
                              if( s[id] == '?') {
                                    for( int i = 0; i < 4; i++ ) {
                                          int ux = x + dx[i];
                                          int uy = y + dy[i];

                                          q.push({{ux,uy}, id+1});
                                    }
                              }
                              else {
                                    if( s[id] == 'W') q.push({{x,y-1}, id+1});
                                    if( s[id] == 'E') q.push({{x,y+1}, id+1});
                                    if( s[id] == 'N') q.push({{x-1,y}, id+1});
                                    if( s[id] == 'S') q.push({{x+1,y}, id+1});
                              }
                        }
                  }
            }
      }
      cout << ans.size();

return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 600 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 600 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Runtime error 921 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 600 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Runtime error 921 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -