Submission #1109906

#TimeUsernameProblemLanguageResultExecution timeMemory
1109906HNa_seawjingNautilus (BOI19_nautilus)C++14
66 / 100
1036 ms3408 KiB
#include <bits/stdc++.h>
//code
#define fl(i,x,y,z) for(int i=x;i<=y;i=i+z)
#define fn(i,x,y,z) for(int i=x;i>=y;i=i-z)
#define rep(i,x,y) for(int i=x;i<y;i=i+1)
#define all(v) v.begin(),v.end()
#define pb emplace_back
#define tle cout<<"tle"<<endl
#define edl cout<<"\n"
#define el "\n"
#define getbit(x,i) ((x>>i)&1)
#define bitcnt __builtin_popcount
//ham
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define ld long double
#define inf 0x3f3f3f3f
//#define int long long
template <typename T1, typename T2>
bool minimize(T1 &a, T2 b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool maximize(T1 &a, T2 b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
const int maxn=5005;
int m,n,p;
string s;
bitset <maxn> dp[maxn],et[maxn],f[maxn],a[maxn];
void inp()
{
    cin>>m>>n>>p;
    fl(i,1,m,1)
        fl(j,1,n,1)
        {
            char x; cin>>x;
            if (x=='.') a[i][j]=1;
            else a[i][j]=0;
            dp[i][j]=a[i][j];
        }
    cin>>s;
}
void change(char t,int x)
{
    if (t=='?') f[x]=(dp[x-1]|dp[x+1]|(dp[x]>>1)|(dp[x]<<1))&a[x];
    else if (t=='N') f[x]=dp[x+1]&a[x];
    else if (t=='E') f[x]=(dp[x]<<1)&a[x];
    else if (t=='S') f[x]=dp[x-1]&a[x];
    else if (t=='W') f[x]=(dp[x]>>1)&a[x];
}
void sol()
{
    rep(x,0,s.length())
    {
        fl(i,1,m,1) change(s[x],i);
        fl(i,1,m,1)
        {
            dp[i]=f[i];
            f[i]^=et[i];
        }
//        fl(i,1,m,1)
//        {
//            fl(j,1,n,1)
//                cout<< dp[i][j]<< " ";
//            edl;
//        }
//        edl;
    }
    int cnt=0;
    fl(i,1,m,1)
        cnt+= dp[i].count();
    cout<<cnt;
}
signed main()
{
    #define name "seaw"
    if (fopen(name".inp", "r"))
    {
        freopen(name".inp", "r", stdin);
        freopen(name".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    inp();
    sol();
    return 0;
}
/*   /\_/\
    ( ._. )
    / >V< \
*/

Compilation message (stderr)

nautilus.cpp: In function 'void sol()':
nautilus.cpp:5:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,x,y) for(int i=x;i<y;i=i+1)
......
   69 |     rep(x,0,s.length())
      |         ~~~~~~~~~~~~~~           
nautilus.cpp:69:5: note: in expansion of macro 'rep'
   69 |     rep(x,0,s.length())
      |     ^~~
nautilus.cpp: In function 'int main()':
nautilus.cpp:95:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:96:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...