Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <sstream>
- #define T long long
- void getDeck(std::vector<std::string>& deck);
- void getBorders(std::vector<T>& borders);
- int main()
- {
- using namespace std;
- vector<string> deck;
- vector<T> borders;
- getDeck(deck);
- getBorders(borders);
- borders.insert(borders.begin(), 0);
- T pointer = (T) borders.size() - 1;
- T to = (T) deck.size();
- while (pointer >= 0)
- {
- auto from = (unsigned int) borders[pointer];
- for (unsigned int i = from; i < to; ++i)
- {
- cout << deck[i];
- }
- to = borders[pointer];
- --pointer;
- }
- return 0;
- }
- // Yep, copypaste
- void getBorders(std::vector<T>& borders)
- {
- using namespace std;
- string str;
- T curInt;
- getline(cin, str);
- istringstream stream(str);
- while (stream >> curInt)
- {
- borders.push_back(curInt);
- }
- }
- // Yep, copypaste
- void getDeck(std::vector<std::string>& deck)
- {
- using namespace std;
- string curStr;
- string str;
- getline(cin, str);
- istringstream stream(str);
- while (stream >> curStr)
- {
- deck.push_back(curStr + " ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement