Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <unordered_set>
- #include <map>
- #include <unordered_map>
- #include <random>
- #include <chrono>
- #include <string>
- #include <bitset>
- #include <cassert>
- #include <queue>
- #include <memory>
- //#pragma comment(linker, "/STACK:16777216")
- //#pragma GCC optimize("O3")
- //#pragma GCC optimize("Ofast")
- //#pragma GCC optimize("unroll-loops")
- //#pragma GCC optimize("unswitch-loops")
- //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")
- using namespace std;
- //mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
- #define ll long long
- #define ull unsigned long long
- //#define double long double
- //#define int ll
- //#define int ull
- //#define int short
- //#define int unsigned short
- //#define int unsigned int
- #define mp make_pair
- #define F first
- #define S second
- #define pii pair<int, int>
- #define hash hash228
- const int SZ = 2e5 + 4;
- const double EPS = 1e-7;
- const int mod = 998244353;
- const int hashpow = 127;
- const int inf = 2e9;
- struct custom_hash {
- static uint64_t splitmix64(uint64_t x) {
- // http://xorshift.di.unimi.it/splitmix64.c
- x += 0x9e3779b97f4a7c15;
- x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
- x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
- return x ^ (x >> 31);
- }
- size_t operator()(uint64_t x) const {
- static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
- return splitmix64(x + FIXED_RANDOM);
- }
- };
- int n, k;
- string s;
- void read() {
- cin >> n >> k >> s;
- }
- void solve() {
- vector<set<int>> ans;
- int sum = 0;
- while (true) {
- set<int> tmp;
- for (int j = 0; j < n - 1; ++j) {
- if (s[j] == 'R' && s[j + 1] == 'L') {
- swap(s[j], s[j + 1]);
- tmp.insert(j);
- ++sum;
- ++j;
- }
- }
- if (tmp.empty()) break;
- ans.push_back(tmp);
- }
- if (sum < k || k < ans.size()) {
- cout << -1;
- return;
- }
- int tmp = 0;
- bool z = true;
- for (auto &u : ans) {
- if (z) {
- if (tmp + 1 + sum - u.size() >= k) {
- cout << u.size() << " ";
- for (auto v : u) {
- cout << v + 1 << " ";
- }
- cout << "\n";
- sum -= u.size();
- ++tmp;
- } else {
- int x = tmp + 1 + sum - k;
- int j = 0;
- if (x) {
- cout << x << " ";
- for (auto v : u) {
- cout << v + 1 << " ";
- ++j;
- if (j == x) break;
- }
- cout << "\n";
- }
- int q = 0;
- for (auto v : u) {
- if (q >= j) {
- cout << 1 << " " << v + 1 << "\n";
- }
- ++q;
- }
- z = false;
- }
- } else {
- for (auto v : u) {
- cout << 1 << " " << v + 1 << "\n";
- }
- }
- }
- }
- signed main() {
- #ifdef __LOCAL
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #else
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- #endif
- // int t;
- // cin >> t;
- // for (int i = 0; i < t; ++i) {
- read();
- solve();
- // }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement