Submission #1206677

#TimeUsernameProblemLanguageResultExecution timeMemory
1206677dksnfjkfnwkfwNautilus (BOI19_nautilus)C++20
0 / 100
1 ms320 KiB
#include <bits/stdc++.h>
using namespace std;

#define sonic ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define IO(main) if(fopen(main".inp","r")){freopen(main".inp","r",stdin);freopen(main".out","w",stdout);}
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define pb push_back
#define el cout << endl
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MASK(i) ((1LL)<<(i))
#define BIT(x,i) (((x)>>(i))&(1LL))
#define FOR(i, a, b) for(int (i)=(a);(i)<=(b); i++)
#define FORD(i, a, b) for(int (i)=(a);(i)>=(b); i--)


using ll = long long;
using ull = unsigned long long;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<pii>;

const int N = 1e6 + 9;
const int mod = 1e9 + 7;
const ll INF = 1e18 + 7;
const int base = 31;
const int LOG = 20;
const ll MOD = 1e9 + 7;

int mul(int x, int y) {return 1LL * x * y % mod;}
int calPw(int x, int y)
{
    int ans = 1;
    while(y)
    {
        if (y&1) ans = 1LL * ans * x % mod;
        x = 1LL * x * x % mod;
        y >>= 1;
    }
    return ans;
}
int d4x[4] = {1, 0, -1, 0};
int d4y[4] = {0, 1, 0, -1};
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
///Author: Le Chi Thien Luong The Vinh high school 2008
///code
template<class X, class Y>
bool minimize(X &x , Y y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}
template<class X, class Y>
bool maximize(X &x , Y y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class X, class Y>
bool add(X &x , Y y){
    if((x + y ) >= mod){
        ll tmp  = x + y;
        x = tmp - mod;
        return true;
    }
    return false;
}
void Solve(){

}
string s;
string qr = "SENW";
char a[101][101];
int n, m, sz;
pii pre[N];
bool inside(int x, int y){
    return 1 <= x && x <= n && 1 <= y && y <= m;
}
void Read(){
    cin >> n >> m >> sz;
    FOR(i, 1, n){
        FOR(j, 1, m){
            cin >> a[i][j];
        }
    }
    cin >> s;
    s = ' ' + s;
    FOR(i, 1, sz){
        if(s[i] == 'S')pre[i].fi++;
        if(s[i] == 'N')pre[i].fi--;
        if(s[i] == 'E')pre[i].se++;
        if(s[i] == 'W')pre[i].se--;
        pre[i].fi += pre[i - 1].fi;
        pre[i].se += pre[i - 1].se;
    }
    set<pii>vc;
    FOR(i, 1, n){
        FOR(j, 1, m){
            if(a[i][j] == '#')continue;
            bool ok = 1;
            FOR(x, 1, sz){
                int nx = i + pre[x].fi;
                int ny = j + pre[x].se;
                if(inside(nx, ny) == 0 || a[nx][ny] == '#')ok=0;
            }
            int nxx = i + pre[sz].fi;
            int nyy = j + pre[sz].se;
            if(ok){
                vc.insert({nxx, nyy});
            }
        }
    }
    cout << vc.size();
}



int main()
{
    sonic;
    freopen("nautilus.inp","r",stdin);
    freopen("nautilus.out","w",stdout);
    int TEST = 1;
   // cin >> TEST;
    while(TEST--)
    {

        Read();
        Solve();
    }
}

Compilation message (stderr)

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