Codeforces Round #754 (Div. 2) B. Reverse Sort
卡题原因:将自己的思想代入到了题目要求中。
题目要求一次操作可以操作多个数字,但是我认为要最小化数字数量。
实际上,要么是0次操作,要么是1次操作。
#include#include if(count(c, c+i, '1') == 0) continue; if(count(c, c+i, '1') == count(c+i, c+n, '0')) { cout<<1<<'\n'<<2*count(c, c+i, '1')<<" "; for(int j=0;jif(c[j] == '1') cout<#include #include using namespace std; int main(){ int t; scanf("%d",&t); while(t--){ int n; cin>>n; char c[n+1]; cin>>c; vector<int> v; bool flag=0; for(int i=0;i ){ 1<<" "; for(int j=i;j if(c[j] == '0') cout< 1<<" "; cout<<'\n'; flag=1; break; } } if(flag)continue; cout<<0<<'\n'; } return 0; }