Codeforces Round #754 (Div. 2) B

原题:https://codeforces.com/contest/1605/problem/B

代码:

 1 #include<bits/stdc++.h>
 2 #define N 1000006
 3 using namespace std;
 4 char ch[N];
 5 void solve()
 6 {
 7     vector<int>vec;
 8     string s;
 9     int n,c0=0,c1=0;
10     cin>>n>>s;
11     for(int i=0;i<n;i++){
12         if(s[i]=='0')c0++;
13         else c1++;
14     }
15     for(int i=0;i<c0;i++){
16         if(s[i]=='1')vec.push_back(i+1);
17     }
18     if(vec.size()==0){
19         cout<<0<<endl;
20         return;
21     }
22     for(int i=c0;i<n;i++){
23         if(s[i]=='0')vec.push_back(i+1);
24     }
25     cout<<1<<endl<<vec.size()<<" ";
26     for(auto it:vec){
27         cout<<it<<" ";
28     }
29     puts("");
30 } 
31 int main()
32 {
33     int t;
34     cin>>t;
35     while(t--)
36         solve();
37     return 0;
38 }
39 //完全不理解,操作是检查字符串和应该的最终结果哪里有差别,就存位置,鬼知道为什么

 

posted @ 2021-11-13 23:58  20kmのshimakaze  阅读(58)  评论(0)    收藏  举报