Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_DEPRECATE
- #include <iostream>
- #include <vector>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #define ull unsigned long long
- #define ll long long
- using namespace std;
- const int N = 1001;
- const ll INF = 1000ll * 1000 * 1000;
- //ll a[N];
- pair<int, int> d[N];
- int p[N];
- int dx[3] = { 2, 3, 6 };
- int main() {
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- int n;
- cin >> n;
- string s;
- cin >> s;
- d[0] = { 0, 0 };
- for (int i = 1; i < n; i++) {
- d[i] = { INF, 0 };
- if (s[i] == 'w')
- continue;
- for (int j = 0; j < 3; j++) {
- if (i - dx[j] >= 0 && d[i - dx[j]].first != INF){
- if (d[i].first > d[i - dx[j]].first + 1) {
- d[i] = d[i - dx[j]];
- d[i].first++;
- p[i] = i - dx[j];
- }
- else {
- if (d[i].first == d[i - dx[j]].first + 1 && d[i].second > d[i - dx[j]].second) {
- d[i] = d[i - dx[j]];
- d[i].first++;
- p[i] = i - dx[j];
- }
- }
- }
- }
- if (s[i] == '"') {
- d[i].second++;
- }
- }
- if (d[n - 1].first == INF) {
- cout << -1;
- return 0;
- }
- cout << d[n - 1].first << ' ' << d[n - 1].second << endl;
- vector<int> r;
- int c = n - 1;
- while (c != 0) {
- r.push_back(c);
- c = p[c];
- }
- r.push_back(0);
- for (int i = r.size() - 1; i >= 0; i--) {
- cout << r[i] + 1 << ' ';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement