Code Submission Evaluation System Login

CSES - HIIT Open 2017

HIIT Open 2017

Contest start:2017-05-27 11:00:00
Contest end:2017-05-27 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard


History
2017-05-27 11:12:12
Task:Dynamic duo
Sender:Nää jäbät
Submission time:2017-05-27 11:12:12
Status:READY
Result:ACCEPTED

Show test data

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:16:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < a.length(); i++) {
                                      ^

Code

#include <bits/stdc++.h>

#define ll long long

using namespace std;

int main () {
    string s;
    cin>>s;
    sort(s.begin(), s.end());
    if (s.length() % 2) {
        cout<<-1<<endl;
    } else {
        string a = s.substr(0, s.length() / 2);
        string b = s.substr(s.length() / 2);
        for (int i = 0; i < a.length(); i++) {
            if (a[i] == b[i]) {
                cout<<-1<<endl;
                return 0;
            }
        }
        cout<<a<<endl<<b<<endl;
    }
}