Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <cstring>
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- typedef unsigned int uint;
- using namespace std;
- string s[20000], ans;
- int n, u = 0, o;
- void check(int r, int t)
- {
- string st, s1;
- int y = 0;
- for (int i = 0; i < r; i++)
- st += s[i] + (char)92;
- st += "...";
- st += (char)92;
- for(int i = t; i < n; i++)
- s1 += s[i] + (char)92;
- s1.resize(s1.size() - 1);
- st += s1;
- if (st.size() > o) return;
- if (st.size() > ans.size() || (st.size() == ans.size() && s1.size() > u))
- ans = st, u = s1.size();
- }
- int main()
- {
- char c;
- cin >> o;
- while (cin >> c)
- {
- if (c == 92) n++;
- else s[n] += c;
- }
- n++;
- for (int i = 0; i < n; i++) ans += s[i] + (char)92;
- ans.resize(ans.size() - 1);
- if (o >= ans.size()) return cout << ans, 0;
- ans = "";
- for (int i = 2; i < n - 1; i++)
- for (int j = i + 1; j < n; j++)
- check(i, j);
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement