Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <algorithm>
- #include <sstream>
- using namespace std;
- bool cmp(istringstream &s) {
- vector<string> a;
- string word;
- while (s >> word) {
- a.push_back(word);
- }
- if (a.empty()) {
- cout << "Yes\n";
- exit(0);
- }
- int n = a.size();
- if (n % 2 != 0) {
- return false;
- }
- for (int i = 0; i < n/2; ++i) {
- if (a[i] != a[n/2 + i]) {
- return false;
- }
- }
- return true;
- }
- int main() {
- string line;
- while (getline(cin, line)) {
- istringstream s(line);
- if (!cmp(s)) {
- cout << "No\n";
- exit(0);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment