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:11:09
Task:Dynamic duo
Sender:Game of Nolife
Submission time:2017-05-27 11:11:09
Status:READY
Result:ACCEPTED

Show test data

Code

#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int n=s.size()/2;
	sort(s.begin(),s.end());
	for (int i=0;i<n;i++) {
		if (s[i]==s[i+n]) {
			cout<<"-1\n";
			return 0;
		}
	}
	for (int i=0;i<n;i++) cout<<s[i];
	cout<<"\n";
	for (int i=n;i<2*n;i++) cout<<s[i];
	cout<<"\n";
}