| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 540865 | Olympia | Nautilus (BOI19_nautilus) | C++17 | 1045 ms | 51452 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cmath>
#include <iostream>
#include <set>
#include <climits>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <string>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <type_traits>
#include <string>
#include <queue>
#define ll long long
#include <map>
using namespace std;
vector<string> vec;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
set<pair<int,int>> pos;
int R, C, M;
cin >> R >> C >> M;
vec.resize(R);
for (int i = 0; i < R; i++) {
cin >> vec[i];
assert(vec[i].size() == C);
}
string s;
cin >> s;
set<pair<int,int>> orig;
for (int i = 0; i < R; i++) {
for (int j = 0; j < C; j++) {
if (vec[i][j] == '.') {
pos.insert({i, j});
}
}
}
orig = pos;
map<char,pair<int,int>> myMap;
myMap['W'] = {0, -1};
myMap['E'] = {0, 1};
myMap['S'] = {1, 0};
myMap['N'] = {-1, 0};
for (int i = 0; i < s.length(); i++) {
set<pair<int,int>> valid;
for (char c: {'W', 'N', 'S', 'E'}) {
if (s[i] == c || s[i] == '?') {
set<pair<int,int>> new_pos;
for (auto& p: pos) {
int dx = p.first + myMap[c].first;
int dy = p.second + myMap[c].second;
new_pos.insert({dx, dy});
}
vector<pair<int,int>> res;
set_intersection(new_pos.begin(), new_pos.end(), orig.begin(), orig.end(), std::back_inserter(res));
for (auto& p: res) {
valid.insert(p);
}
}
}
pos = valid;
}
cout << pos.size() << '\n';
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
