Submission #721599

# Submission time Handle Problem Language Result Execution time Memory
721599 2023-04-11T05:21:36 Z n0sk1ll Nautilus (BOI19_nautilus) C++14
100 / 100
232 ms 724 KB
#include <bits/stdc++.h>
 
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) (x).begin(),(x).end()
#define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++)
#define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)
#define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--)
 
using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;
 
 
 
 
 
 
 
//Note to self: Check for overflow
 
bitset<512> tab[512];
bitset<512> cur[512];
bitset<512> pom[512];
bitset<512> nula;
 
int solve(string &command, int n, int m)
{
    ff(i,0,n) cur[i]=tab[i];
    for (auto c : command)
    {
        if (c=='E')
        {
            ff(i,0,n) cur[i]=((cur[i]<<1)&tab[i]);
        }
        else if (c=='W')
        {
            ff(i,0,n) cur[i]=((cur[i]>>1)&tab[i]);
        }
        else if (c=='N')
        {
            ff(i,0,n) cur[i]=(cur[i+1]&tab[i]);
        }
        else if (c=='S')
        {
            bff(i,1,n) cur[i]=(cur[i-1]&tab[i]);
            cur[0]=nula;
        }
        else
        {
            ff(i,0,n) pom[i]=0;
            ff(i,0,n) pom[i]|=(cur[i]<<1);
            ff(i,0,n) pom[i]|=(cur[i]>>1);
            ff(i,1,n) pom[i]|=(cur[i-1]);
            ff(i,0,n-1) pom[i]|=(cur[i+1]);
            ff(i,0,n) cur[i]=(pom[i]&tab[i]);
        }
    }
 
    int ret=0;
    ff(i,0,n) ret+=(cur[i].count());
    return ret;
}
 
int main()
{
    FAST;
 
    int n,m,q; cin>>n>>m>>q;
 
    ff(i,0,n)
    {
        string s; cin>>s;
        ff(j,0,m) tab[i][j]=(s[j]=='.');
    }
 
    string command;
    cin>>command;
 
    cout<<solve(command,n,m);
}

Compilation message

nautilus.cpp: In function 'int solve(std::string&, int, int)':
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:44:5: note: in expansion of macro 'ff'
   44 |     ff(i,0,n) cur[i]=tab[i];
      |     ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:49:13: note: in expansion of macro 'ff'
   49 |             ff(i,0,n) cur[i]=((cur[i]<<1)&tab[i]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:53:13: note: in expansion of macro 'ff'
   53 |             ff(i,0,n) cur[i]=((cur[i]>>1)&tab[i]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:57:13: note: in expansion of macro 'ff'
   57 |             ff(i,0,n) cur[i]=(cur[i+1]&tab[i]);
      |             ^~
nautilus.cpp:14:29: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   14 | #define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)
      |                             ^
nautilus.cpp:61:13: note: in expansion of macro 'bff'
   61 |             bff(i,1,n) cur[i]=(cur[i-1]&tab[i]);
      |             ^~~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:66:13: note: in expansion of macro 'ff'
   66 |             ff(i,0,n) pom[i]=0;
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:67:13: note: in expansion of macro 'ff'
   67 |             ff(i,0,n) pom[i]|=(cur[i]<<1);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:68:13: note: in expansion of macro 'ff'
   68 |             ff(i,0,n) pom[i]|=(cur[i]>>1);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:69:13: note: in expansion of macro 'ff'
   69 |             ff(i,1,n) pom[i]|=(cur[i-1]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:70:13: note: in expansion of macro 'ff'
   70 |             ff(i,0,n-1) pom[i]|=(cur[i+1]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:71:13: note: in expansion of macro 'ff'
   71 |             ff(i,0,n) cur[i]=(pom[i]&tab[i]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:76:5: note: in expansion of macro 'ff'
   76 |     ff(i,0,n) ret+=(cur[i].count());
      |     ^~
nautilus.cpp: In function 'int main()':
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:86:5: note: in expansion of macro 'ff'
   86 |     ff(i,0,n)
      |     ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:89:9: note: in expansion of macro 'ff'
   89 |         ff(j,0,m) tab[i][j]=(s[j]=='.');
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 95 ms 676 KB Output is correct
23 Correct 101 ms 676 KB Output is correct
24 Correct 102 ms 676 KB Output is correct
25 Correct 92 ms 676 KB Output is correct
26 Correct 93 ms 716 KB Output is correct
27 Correct 165 ms 596 KB Output is correct
28 Correct 172 ms 672 KB Output is correct
29 Correct 170 ms 596 KB Output is correct
30 Correct 169 ms 596 KB Output is correct
31 Correct 168 ms 724 KB Output is correct
32 Correct 226 ms 668 KB Output is correct
33 Correct 231 ms 668 KB Output is correct
34 Correct 232 ms 676 KB Output is correct
35 Correct 221 ms 596 KB Output is correct
36 Correct 228 ms 692 KB Output is correct