Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <bits/stdc++.h>
- #define zero '0'
- using namespace std;
- int main(){
- ifstream cin;
- ofstream cout;
- cin.open("input.txt");
- cout.open("output.txt");
- string st = "";
- vector <int> a;
- int pr = 0;
- int cn = 0;
- cin >> st;
- pr = st[0]-zero;
- cn++;
- //cout << st.length() << endl;
- for (int i=1; i<st.length(); i++){
- //cout << pr << endl;
- if (cn==pr+1){
- a.push_back(pr);
- //cout << st[i] << " ";
- pr = st[i]-zero;
- cn=0;
- }
- if (pr!=(st[i]-zero)){
- //cout << pr << endl;
- //cout << cn << endl;
- if (cn==pr+1){
- a.push_back(pr);
- //cout << st[i] << " ";
- pr = st[i]-zero;
- cn=0;
- }else{
- cout << -1;
- return 0;
- }
- }
- cn++;
- //cout << endl;
- }
- if (cn==pr+1){
- a.push_back(pr);
- //cout << st[i] << " ";
- pr = st[st.size()-1]-zero;
- cn=0;
- }else{
- cout << -1;
- return 0;
- }
- st ="";
- for (int i = 0; i<a.size(); i++){
- // cout << a[i];
- st += a[i]+'0';
- }
- int zz = atoi(st.c_str());
- if (zz<=1000000){
- cout << zz;
- }else{
- cout << "-1";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement