正文
增加 44 行删除 37 行
12 行未改动13141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596012 行未改动## 代码```cpp line-numbers#include<bits/stdc++.h>using namespace std;int main(){int n,shao=0,yu=0,NBA=0;string s;cin >> n >> s;int t = 1;for(char c : s)if(c == '1') t ^= 1;int co = 0, ce = 0;for(int i = 1; i <= n; ++i)if(i & 1) co++;else ce++;int st = 1, ro = 1, re = 0;for(char c : s){if(c == '1') st ^= 1;if(st) ro++;else re++;}if(ro != co or re != ce){cout << -1;return 0;}vector<int> O,E;for(int i = 1; i <= n; ++i)if(i & 1) O.push_back(i);else E.push_back(i);vector<int> A;int p = 0, q = 0;A.push_back(O[p++]);st = 1;for(char c : s){if(c == '1') st ^= 1;if(st) A.push_back(O[p++]);else A.push_back(E[q++]);}for(int x : A) cout << x << " ";return 0;}12 行未改动1314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666712 行未改动## 代码```cpp line-numbers#include<bits/stdc++.h>using namespace std;int shao=0,yu=0,NBA=0;int n;string s;vector<int> O,E;vector<int> g(int st){int co=0,ce=0;int now=st;if (now == 1) co++;else ce++;for(char c : s){if(c == '1')now ^= 1;if (now == 1)co++;else ce++;}if(co != O.size() || ce != E.size())return {};vector<int> a;int p1=0,p2=0;now=st;if (now == 1)a.push_back(O[p1++]);elsea.push_back(E[p2++]);for(char c : s){if(c == '1')now ^= 1;if (now == 1)a.push_back(O[p1++]);else a.push_back(E[p2++]);}return a;}int main(){cin >> n >> s;for(int i = 1; i <= n; i++){if(i & 1)O.push_back(i);else E.push_back(i);}auto a = g(1);if(!a.empty()){for(int x : a)cout << x << " ";return 0;}a = g(0);if(!a.empty()){for(int x : a)cout << x << " ";return 0;}cout << -1;}