-
Notifications
You must be signed in to change notification settings - Fork 1
/
RNG.cpp
73 lines (56 loc) · 1.33 KB
/
RNG.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
bool xxx(int a,int b){
return a>b;
}
int main(){
char biti;
int cnt=0,cntmax=0,altcnt=0;
vector<char>vec;
vector<int>out;
int n;
int x;
cin>>n;
for(int i=0;i<n;i++){
cin>>biti;
vec.push_back(biti);
}
for(int i=0;i<vec.size();i++){
if(vec[i]=='1'){
cnt++;
if(cnt>cntmax){
cntmax=cnt;
}
}else{cnt=0;}
}
for(int j=cntmax;j>=1;j--){
for(int i=0;i<vec.size();i++){
if(vec[i]=='1'){
cnt++;
if(cnt==j&&vec[i+1]!='1'){
altcnt++;
}
}else{cnt=0;}
}
out.push_back(altcnt);
//cout<<altcnt<<' ';
altcnt=0;
cnt=0;
}
vector<int>vec2;
for(int i=out.size()-1;i>=0;i--){
vec2.push_back(out[i]);
}
sort(out.begin(),out.end(),xxx);
for(int i=0;i<vec2.size();i++){
cout<<vec2[i]<<' ';
}cout<<endl;
if(out==vec2){
cout<<'1';
}else{cout<<'0';
//cout<<altcnt;
}}