hiho week 165 register

Ended

Participants:334

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-28 14:31:59

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
using namespace std;
int main()
{
    string tmp_s = "abcdefghijklmnopqrstuvwxyz";
    int c_num[26];
    for (int i = 0; i < 26; ++i)
        c_num[i] = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); ++i)
        c_num[tmp_s.find(s[i])]++;
    for (int i = 0; i < 26; ++i)
        if (c_num[i] > (s.length() + 1)/2)
        {
            cout << "INVALID" << endl;
            return 0;
        }
    string res = "";
    char last_c = '#';
    int len = s.length();
    for (int i = 0; i < 26; ++i)
        if (c_num[i] > 0 && tmp_s[i] != last_c)
        {
            bool flag = true;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX