Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <vector>
- #include <stdio.h>
- #include <cmath>
- #include <math.h>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <deque>
- #include <ctime>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef unsigned int ui;
- #define mh() make_heap()
- #define poph() pop_heap()
- #define pushh() push_heap()
- #define sor(n) n.begin(), n.end()
- #define mp make_pair
- #define files freopen("vampire.in", "rt", stdin); freopen("vampire.out", "wt", stdout)
- #define formx(a1,b1,c1,a2,b2,c2) ((a1*c2-a2*c1)/(a1*b2-b1*a2))
- #define formy(a1,b1,c1,a2,b2,c2) ((c1*b2-c2*b1)/(a1*b2-b1*a2))
- #define forma(y1,y2) (y2-y1)
- #define formb(x1,x2) (x1-x2)
- #define formc(x1,y1,x2,y2) (x1*(y2-y1)-y1*(x2-x1))
- #define ras(x1,y1,x2,y2) sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
- struct cord
- {
- double x1, y1, x2, y2;
- };
- struct limcord
- {
- double x, y;
- bool good;
- };
- bool checkparal(double a1, double a2, double b1, double b2)
- {
- return a1 / b1 == a2 / b2;
- }
- limcord findt(cord c, cord now)
- {
- double a1 = forma(now.y1, now.y2);
- double b1 = formb(now.x1, now.x2);
- double c1 = formc(now.x1, now.y1, now.x2, now.y2);
- double a2 = forma(c.y1, c.y2);
- double b2 = formb(c.x1, c.x2);
- double c2 = formc(c.x1, c.y1, c.x2, c.y2);
- if (!checkparal(a1, a2, b1, b2))
- {
- double x = formx(a1, b1, c1, a2, b2, c2);
- double y = formy(a1, b1, c1, a2, b2, c2);
- return{ x,y, true };
- }
- else
- {
- return{ NULL,NULL, false };
- }
- }
- bool checkT(limcord now, cord ot)
- {
- if (ras(ot.x1, ot.y1, ot.x2, ot.y2) == ras(ot.x1, ot.y1, now.x, now.y) + ras(ot.x2, ot.y2, now.x, now.y))
- return true;
- else
- return false;
- }
- string check(map<int, set<string>> dic, string word)
- {
- if (dic.find(word.size()) != dic.end())
- if (dic[word.size()].find(word) != dic[word.size()].end())
- return word;
- else
- {
- for (auto i = dic[word.size()].begin(); i != dic[word.size()].end(); i++)
- {
- int s = 0;
- string prom = *i;
- for (int j = 0; j <= i->size() - 1; j++)
- {
- if (word[j] != prom[j])
- s++;
- }
- if (s == 1)
- return prom;
- }
- }
- return word;
- }
- int main()
- {
- //files;
- /*int n;
- string text;
- map<int, set<string>> dic;
- string prom;
- vector <string> answ;
- cin >> prom;
- while (prom != "#")
- {
- dic[prom.size()].insert(prom);
- cin >> prom;
- }
- int corr = 0;
- getline(cin, prom);
- while (getline(cin, prom))
- {
- string word;
- char lasts = 0;
- int last = 0;
- string line = "";
- for (int i = 0; i <= prom.size() - 1; i++)
- {
- if (prom[i] < 'a' || prom[i] > 'z')
- if (lasts >= 'a'&&lasts <= 'z')
- {
- word = prom.substr(last, i - last);
- string o = word;
- word = check(dic, word);
- if (o != word)
- corr++;
- line += word;
- line += prom[i];
- }
- else
- line += prom[i];
- else
- if (i == prom.size() - 1)
- {
- if (prom[i] == 13)
- {
- prom = "";
- break;
- }
- else
- {
- word = prom.substr(last, i - last + 1);
- string o = word;
- word = check(dic, word);
- if (o != word)
- corr++;
- line += word;
- }
- }
- else
- if (lasts < 'a' || lasts > 'z')
- last = i;
- lasts = prom[i];
- }
- answ.push_back(line);
- }
- for (auto i = answ.begin(); i != answ.end(); i++)
- {
- cout << *i << endl;
- }
- cout << corr;*/
- string u;
- string d;
- cin >> u;
- cin >> d;
- queue <char> N;
- queue <char> S;
- for (int i = 0; i < u.size(); i++)
- {
- N.push(u[i]);
- }
- for (int i = 0; i < d.size(); i++)
- {
- S.push(d[i]);
- }
- int answ = 0;
- while (!S.empty() && !N.empty())
- {
- char s = S.front();
- char n = N.front();
- if (s != 'L'&&n != 'L')
- {
- answ++;
- S.pop();
- N.pop();
- }
- else
- if (s == 'L'&&n != 'L')
- {
- answ++;
- N.pop();
- }
- else
- {
- if (s != 'L'&&n == 'L')
- {
- answ++;
- S.pop();
- }
- else
- {
- answ++;
- S.pop();
- N.pop();
- }
- }
- }
- answ += S.size() + N.size();
- cout << answ;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement