Submission #925889

#TimeUsernameProblemLanguageResultExecution timeMemory
925889vjudge1Nautilus (BOI19_nautilus)C++17
66 / 100
1022 ms39948 KiB
/* no more temmy :( */ #include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; // #include<icecream.hpp> // using namespace icecream; #define ll long long #define int ll #define ld long double #define y1 cheza // mt19937 rng(1983413); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; const int N=510; const int M=1e6; const int B=317; const int mod=998244353; const int INF=1e18; const int lg=64; const int dx[]={1,-1,0,0}; const int dy[]={0,0,1,-1}; const double eps=1e-9; int n,m,k; char a[N][N]; int rv[N]; string s; bool check(int x,int y){ if(x<1||y<1||x>n||y>m||a[x][y]=='#')return 0; return 1; } vector<pair<int,int>>q,q2; void shrink(){ sort(q.begin(),q.end()); q.resize(unique(q.begin(),q.end())-q.begin()); } void test(){ cin>>n>>m>>k; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>a[i][j]; } } cin>>s; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(a[i][j]=='.'){ q.push_back({i,j}); } } } for(int i=0;i<k;i++){ for(auto [x,y]:q){ if(s[i]=='?'){ for(int j=0;j<4;j++){ int x1=x+dx[j]; int y1=y+dy[j]; if(check(x1,y1)){ q2.push_back({x1,y1}); } } } else{ for(int j=rv[s[i]];j<=rv[s[i]];j++){ int x1=x+dx[j]; int y1=y+dy[j]; if(check(x1,y1)){ q2.push_back({x1,y1}); } } } } q.swap(q2); q2.clear(); shrink(); } cout<<q.size()<<'\n'; } /* */ signed main(){ rv['N']=1; rv['S']=0; rv['W']=3; rv['E']=2; // ic.prefix("debug->| "); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); ios_base::sync_with_stdio(false); cin.tie(nullptr); // cout.tie(nullptr); long long t2=1; // cin>>t2; for(int i=1;i<=t2;i++){ test(); } return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'void test()':
nautilus.cpp:70:34: warning: array subscript has type 'char' [-Wchar-subscripts]
   70 |                 for(int j=rv[s[i]];j<=rv[s[i]];j++){
      |                                  ^
nautilus.cpp:70:46: warning: array subscript has type 'char' [-Wchar-subscripts]
   70 |                 for(int j=rv[s[i]];j<=rv[s[i]];j++){
      |                                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...