Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define pb push_back
- #define mp make_pair
- #define sz(x) (int)(x).size()
- #define ll long long
- #define ld long double
- #define ft first
- #define sc second
- #define pii pair<int, int>
- #define pll pair<ll, ll>
- #define forn(i, t) for(int i = 0; i < (t); i++)
- #define fore(i, f, t) for(int i = (f); i < (t); i++)
- #define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
- #define all(x) (x).begin(), (x).end()
- #define ins insert
- using namespace __gnu_pbds;
- using namespace std;
- const int INF = 2147483647;
- const int MOD = 1000000007;
- const ll INF64 = 9223372036854775807;
- const ld EPS = 1e-7;
- set<pair<string, string> > ans;
- /*set<string> used, ans;
- void dfs(string s, string k){
- int n = sz(s);
- string t;
- used.insert(s);
- // ans.insert(mp(s, k));
- bool fl = 0;
- fore(i, 1, n){
- if (s[i - 1] == 'n' && s[i] == 'n'){
- t = s.substr(0, i - 1);
- if (i != n - 1)
- t += s.substr(i + 1, n - (i + 1));
- dfs(t, k + '1');
- fl = 1;
- }
- else if (s[i - 1] == 'n' && s[i] == 't'){
- t = s.substr(0, i - 1) + 'f';
- if (i != n - 1)
- t += s.substr(i + 1, n - (i + 1));
- dfs(t, k + '2');
- fl = 1;
- }
- else if (s[i - 1] == 'n' && s[i] == 'f'){
- t = s.substr(0, i - 1) + 't';
- if (i != n - 1)
- t += s.substr(i + 1, n - (i + 1));
- dfs(t, k + '3');
- fl = 1;
- }
- else if (s[i - 1] == 'f' && s[i] == 'o'){
- t = s.substr(0, i - 1);
- if (i != n - 1)
- t += s.substr(i + 1, n - (i + 1));
- dfs(t, k + '4');
- fl = 1;
- }
- else if (s[i - 1] == 'o' && s[i] == 'f'){
- t = s.substr(0, i - 1);
- if (i != n - 1)
- t += s.substr(i + 1, n - (i + 1));
- dfs(t, k + '5');
- fl = 1;
- }
- }
- fore(i, 1, n - 1){
- if (s[i - 1] == 't' && s[i] == 'o' && s[i + 1] == 't'){
- t = s.substr(0, i - 1) + 't';
- if (i != n - 2)
- t += s.substr(i + 2, n - (i + 2));
- dfs(t, k + '6');
- fl = 1;
- }
- }
- if (!fl)
- ans.ins(k);
- }*/
- // vector<string> a = {"<>*<", "em", "d|", "d>", "dm", "|>*<", "e|", "e>"};
- // vector<string> b = {"<e", "|e", "|md", ">", "md", ">*<d", "e", ">"};
- // vector<int> c = {5, 7, 2, 4, 3, 1, 6, 8};
- vector<string> a = {"|>*<", "d|", "dm", "d>", "<>*<", "e|", "em", "e>"};
- vector<string> b = {">*<d", "|md", "md", ">", "<e", "e", "|e", ">"};
- void dfs(string s, string ans){
- bool fl = 0;
- forn(i, sz(a))
- if (s.find(a[i]) != string::npos){
- ans += ('1' + i);
- string t = s;
- t.replace(t.find(a[i]), sz(a[i]), b[i]);
- dfs(t, ans);
- fl = 1;
- break;
- }
- if (!fl){
- cout << ans << "\n";
- }
- }
- // 5. -> <e
- // 7. em -> |e
- // 2. d| -> |md
- // 4. d> -> >
- // 3. dm -> md
- // 1. |>*< -> >*<d
- // 6. e| -> e
- // 8. e> -> >
- // 57243168
- int main(){
- // dfs("fonfont", "");
- dfs("<|>*<||>", "");
- // cout << "vector<string> a = {";
- // forn(i, sz(c))
- // forn(j, sz(c))
- // if (c[j] == i + 1)
- // cout << '"' << a[j] << '"' << ", ";
- // cout << "};\n";
- // cout << "vector<string> b = {";
- // forn(i, sz(c))
- // forn(j, sz(c))
- // if (c[j] == i + 1)
- // cout << '"' << b[j] << '"' << ", ";
- // cout << "};\n";
- /*cout << sz(ans) << "\n";
- for (auto it = ans.begin(); it != ans.end(); it++)
- cout << *it << "\n";*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement