# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
554655 |
2022-04-29T04:19:07 Z |
ac2hu |
Nautilus (BOI19_nautilus) |
C++14 |
|
137 ms |
724 KB |
#include <bits/stdc++.h>
#ifdef DEBUG
#include "../templates/debug.h"
#else
#define deb(x...)
#endif
using namespace std;
// We can do this using bitsets but we need some way to keep track of the #s
/* Case 1: N, S, E, W we shift the bitset (and) it with current mask
* Case 2: ? or all 4 shifted masks and then (and) it with current mask
*/
const int N = 501;
using B = bitset<N>;
int r,c;
vector<B> ocean, msk;
vector<B> north(){
vector<B> temp(r);
for(int i = 0;i<r - 1;i++){
temp[i] = ocean[i + 1];
}
return temp;
}
vector<B> south(){
vector<B> temp(r);
for(int i = 0;i<r - 1;i++){
temp[i + 1] = ocean[i];
}
return temp;
}
vector<B> west(){
vector<B> temp = ocean;
for(int i = 0;i<r;i++){
temp[i] = temp[i] << 1;
}
return temp;
}
vector<B> east(){
vector<B> temp = ocean;
for(int i = 0;i<r;i++){
temp[i] = temp[i] >> 1;
}
return temp;
}
void ord(vector<B> &o, vector<B> so){
for(int i = 0;i<r;i++){
o[i] |= so[i];
}
}
signed main(){
iostream::sync_with_stdio(false);cin.tie(nullptr);
int m;cin >> r >> c >> m;
ocean.resize(r);
for(int i = 0;i<r;i++){
string t;cin >> t;
for(int j = 0;j<c;j++){
if(t[j] == '.'){
ocean[i][j] = 1;
}
}
}
msk = ocean;
string s;cin >> s;
for(int i = 0;i<s.size();i++){
vector<B> so;
if(s[i] == '?'){
so = north();
ord(so, south());
ord(so, west());
ord(so, east());
}
else{
if(s[i] == 'N'){
so = north();
}
else if(s[i] == 'S'){
so = south();
}
else if(s[i] == 'E'){
so = west();
}
else{
so = east();
}
}
ocean = so;
for(int j = 0;j<r;j++)
ocean[j] &= msk[j];
}
int cc = 0;
for(int i = 0;i<r;i++){
for(int j = 0;j<c;j++){
if(ocean[i][j] == 1)
cc++;
}
}
cout << cc << "\n";
}
Compilation message
nautilus.cpp: In function 'int main()':
nautilus.cpp:63:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int i = 0;i<s.size();i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 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 |
340 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 |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 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 |
340 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 |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
59 ms |
704 KB |
Output is correct |
23 |
Correct |
64 ms |
704 KB |
Output is correct |
24 |
Correct |
62 ms |
716 KB |
Output is correct |
25 |
Correct |
63 ms |
704 KB |
Output is correct |
26 |
Correct |
65 ms |
716 KB |
Output is correct |
27 |
Correct |
98 ms |
704 KB |
Output is correct |
28 |
Correct |
92 ms |
596 KB |
Output is correct |
29 |
Correct |
111 ms |
724 KB |
Output is correct |
30 |
Correct |
97 ms |
704 KB |
Output is correct |
31 |
Correct |
93 ms |
704 KB |
Output is correct |
32 |
Correct |
129 ms |
596 KB |
Output is correct |
33 |
Correct |
137 ms |
596 KB |
Output is correct |
34 |
Correct |
124 ms |
596 KB |
Output is correct |
35 |
Correct |
115 ms |
596 KB |
Output is correct |
36 |
Correct |
116 ms |
704 KB |
Output is correct |