## 思路

### 特殊情况

$1 : \texttt{1234} \cancel{\texttt{5}} \\ 2 : \texttt{123} \cancel{\texttt{4}} \texttt{5} \\ 3 : \texttt{12} \cancel{\texttt{3}} \texttt{45} \\ 4 : \texttt{1} \cancel{\texttt{2}} \texttt{345} \\$

### 推广

$1 : \texttt{123} \cancel{\texttt{4}} \texttt{5} \\ 2 : \texttt{12} \cancel{\texttt{3}} \texttt{45} \\ 3 : \texttt{1} \cancel{\texttt{2}} \texttt{345} \\ 1 : \cancel{\texttt{1}} \texttt{2345} \\$

## 代码和实现

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int t;
cin >> t;
while(t--){
int n;
string s;
cin >> n >> s;
int cur0len = 0; // 最后一个连续段如果是 0 的话 cur0len 表示其长度，
// 如果不是的话 cur0len 就是 0
int cur1len = 0; // 和 1 相同
int curn = 2;    // 最开始是两个玩家
for (char ch : s){
int x = ch - '0';
if (x == 0){
cur0len++;   // 当前是 0 的话 0 结尾的连续段会比原来更长
cur1len = 0; // s 的最后一个不是 1 了
} else {
cur1len++;
cur0len = 0;
}
cout << curn - (x ? cur1len : cur0len) << " ";
// 前文中的 n - k
curn++;
}
cout << '\n';
}
}
{"ft_lang_label":"__label__zh","ft_lang_prob":0.9935693,"math_prob":0.9974366,"size":1724,"snap":"2023-40-2023-50","text_gpt3_token_len":1508,"char_repetition_ratio":0.08023256,"word_repetition_ratio":0.0,"special_character_ratio":0.26218098,"punctuation_ratio":0.086419754,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9916604,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-21T21:54:55Z\",\"WARC-Record-ID\":\"<urn:uuid:d34c3a6d-69e1-49bf-9636-3706fe753cb4>\",\"Content-Length\":\"76817\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b052cb48-11b4-4fe3-84a8-0739189100f6>\",\"WARC-Concurrent-To\":\"<urn:uuid:682ee87d-3815-4ec7-9661-5c12b0849915>\",\"WARC-IP-Address\":\"185.199.111.153\",\"WARC-Target-URI\":\"https://ttzytt.com/2022/12/CF1774C/\",\"WARC-Payload-Digest\":\"sha1:APIHOVRRHBU2TMT5YE2S3RWQUOTBISKH\",\"WARC-Block-Digest\":\"sha1:P4WFEYVKPEEMXOBSEFWGAY6L6EGF5B7W\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233506045.12_warc_CC-MAIN-20230921210007-20230922000007-00252.warc.gz\"}"}