Codeforces Round #469 C A. Zebras
題意: 除了開頭和結尾的一個0 能夠單獨存在之外 其餘的 子串都必須01交替 0開頭0結尾 並且這種“zebra” 串 的長度加起來 是母串的長度 輸出每個串的字元所在的位置
解釋樣例1
0 0 1 0 1 0 0
1 2 3 4 5 6 7
3 1 3 4 010
3 2 5 6 010
1 7
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
using namespace std;
const int MAXN=200001;
int len,tot=0,now=0;
char s[MAXN];
vector<int> ans[MAXN];
int main(){
ios::sync_with_stdio(false);
cin>>(s+1);
len=strlen(s+1);
for(int i=1;i<=len;++i){
if(s[i]=='0'){
ans[++now].push_back(i);
}
else{
if(now==0){
cout<<-1;return 0;
}
ans[now--].push_back(i);
}
tot=max(tot,now);
}
if(tot!=now) cout<<-1;
else{
cout<<tot<<endl;
for(int i=1;i<=tot;++i){
int Size=ans[i].size();
cout<<Size;
for(int j=0;j<Size;++j)
cout<<" "<<ans[i][j];
cout<<endl;
}
}
return 0;
}
相關文章
- Codeforces Round #242 (Div. 2) A. Squats
- Codeforces Testing Round #10 A. Forgotten EpisodeGo
- Codeforces Round #213 (Div. 2) A. Good NumberGo
- Codeforces Round #243 (Div. 2) A. Sereja and Mugs
- Codeforces Round #253 (Div. 2) A. Anton and Letters
- Codeforces Round #250 (Div. 2) A. The Child and Homework
- Codeforces Round #244 (Div. 2) A. Police RecruitsUI
- Codeforces Beta Round #76 (Div. 1 Only) A. Frames
- Codeforces Round #249 (Div. 2) A. Black Square
- Codeforces Round #246 (Div. 2) A. Choosing Teams
- Codeforces Round #216 (Div. 2)A. Valera and Plates
- Codeforces Round #209 (Div. 2) A. Table
- Codeforces Round #210 (Div. 2) A. Levko and Table
- Codeforces Round #192 (Div. 2) A. Cakeminator
- Codeforces Round #189 (Div. 2) A. Magic Numbers
- Codeforces Round #228 (Div. 2) A. Fox and Number GameGAM
- Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack
- Codeforces Round #248 (Div. 2) A. Kitahara Haruki's Gift
- Codeforces Round #235 (Div. 2) A. Vanya and Cards
- Codeforces Round #190 DIV.2 A. Ciel and Dancing
- codeforces round #201 Div2 A. Difference Row
- Codeforces Round #207 (Div. 2) A. Group of Students
- Codeforces Round #195 (Div. 2) A. Vasily the Bear and Triangle
- Codeforces Round #206 (Div. 2) A. Vasya and Digital RootGit
- 容斥 + 組合數學 ---Codeforces Round #317 A. Lengthening Sticks
- Codeforces Round #399 (A,B,C)
- (Codeforces Round #136 (Div. 2))A. Little Elephant and Function(遞迴分析,簡單)Function遞迴
- Codeforces Round #470 div2 C
- Codeforces Round #453 (Div. 2) C
- Codeforces Round #452 (Div. 2) C
- Codeforces Round #321 (Div. 2) C DFS
- Educational Codeforces Round 100-C. Busy Robot
- Codeforces Global Round 11 C. The Hard Work of Paparazzi
- Educational Codeforces Round 33 (Rated for Div. 2) C
- Codeforces Round #323 (Div. 2) C gcdGC
- Codeforces Round #325 (Div. 2) C 模擬
- Codeforces Round #359 (Div. 2) C DFS
- Codeforces Round #290 (Div. 2) A,B,C,D