Wednesday, 28 October 2015

Codeforces Gym 100796L - Emoticons Problem_Solution

/*
Tanzila Islam
Southeast University
mail : tanzilamohita@gmail.com
Problem Link : http://codeforces.com/gym/100796/problem/L
*/
#include<string>
#include<iostream>
using namespace std;

int main () {
    int n, l, sc, fc;
    string s;
    while (cin >> n) {
        cin >> s;
        l = s.length();
        sc = 0;
        fc = 0;
        if (n==1){
           cout << "BORED" << endl;
        }
        else {
            for (int i = 0; i < n-1; i++) {
                 if(s[i] == ':') {
                    if(s[i+1] == ')'){
                        sc++;
                       }
               else if (s[i+1] == '('){
                   fc++;
                 }
              }
           else if (s[i] == ')'){
                if (s[i+1] == ':'){
                     fc++;
               }
              }
              else if (s[i] == '('){
                if (s[i+1] == ':'){
                     sc++;
               }
              }
            }
if (fc > sc){
    cout << "SAD" << endl;
}
else if (sc > fc) {
      cout << "HAPPY" << endl;
}
else {
     cout << "BORED" << endl;
}
}
}
return 0;
}

No comments:

Post a Comment