Advertisement
JosepRivaille

P56059: Línies xules

Apr 9th, 2015
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5.  
  6. int main() {
  7.     int k, x = 0, nx = 0;
  8.     string s;
  9.     while (cin >> k) {
  10.         if (k%2 == 0) {
  11.             ++nx;
  12.             while (k != 0) {
  13.                 cin >> s;
  14.                 --k;
  15.             }
  16.         }
  17.         else {
  18.             int pos = 0;
  19.             string ini, mig, fin;
  20.             cin >> s;
  21.             ini = s;
  22.             int k1 = k-1;
  23.             --k;
  24.             while (k != 0) {
  25.                 ++pos;
  26.                 cin >> s;
  27.                 if (pos == k1/2) mig = s;
  28.                 else if (pos == k1) fin = s;
  29.                 --k;
  30.             }
  31.             if (ini == mig && mig == fin) ++x;
  32.             else ++nx; 
  33.         }
  34.     }
  35.     if (x + nx == x) cout << "totes xules" << endl;
  36.     else if (x + nx == nx) cout << "cap de xula" << endl;
  37.     else cout << "dels dos tipus" << endl;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement