Submission #452145

#TimeUsernameProblemLanguageResultExecution timeMemory
452145OzyNautilus (BOI19_nautilus)C++17
100 / 100
120 ms708 KiB
#include <iostream>
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define lli unsigned long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

lli f,c,m;
bitset<502> pas[502],nuevo[502],mapa[502];
char x;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> f >> c >> m;
    rep(i,1,f) {
        rep(j,1,c) {
            cin >> x;
            if (x == '.') mapa[i][j] = true;
            else mapa[i][j] = false;

            pas[i][j] = mapa[i][j];
        }
    }

    rep(T,1,m) {

        cin >> x;
        rep(i,1,f) {

            if (x == 'N') nuevo[i] = pas[i+1]&mapa[i];
            else if (x == 'S') nuevo[i] = pas[i-1]&mapa[i];
            else if (x == 'W') nuevo[i] = (pas[i] >> 1)&mapa[i];
            else if (x == 'E') nuevo[i] = (pas[i] << 1)&mapa[i];
            else {
                nuevo[i] = (pas[i+1] | pas[i-1]);
                nuevo[i] |= (pas[i] << 1)|(pas[i] >> 1);
                nuevo[i] &= mapa[i];
            }

        }

        swap(pas,nuevo);
    }

    lli sum = 0;
    rep(i,1,f) {
        rep(j,1,c) {
            if (pas[i][j] == 1) sum++;
        }
    }
    cout << sum;

}

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
nautilus.cpp:21:5: note: in expansion of macro 'rep'
   21 |     rep(i,1,f) {
      |     ^~~
nautilus.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
nautilus.cpp:22:9: note: in expansion of macro 'rep'
   22 |         rep(j,1,c) {
      |         ^~~
nautilus.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
nautilus.cpp:31:5: note: in expansion of macro 'rep'
   31 |     rep(T,1,m) {
      |     ^~~
nautilus.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
nautilus.cpp:34:9: note: in expansion of macro 'rep'
   34 |         rep(i,1,f) {
      |         ^~~
nautilus.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
nautilus.cpp:52:5: note: in expansion of macro 'rep'
   52 |     rep(i,1,f) {
      |     ^~~
nautilus.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
nautilus.cpp:53:9: note: in expansion of macro 'rep'
   53 |         rep(j,1,c) {
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...