№ |
Отправитель |
Задача |
Язык |
Вердикт |
Время |
Память |
Отослано |
Протест. |
|
272488632 |
Дорешивание:
sunup15 |
1884B
- 18
|
C++20 (GCC 13-64)
|
Превышено ограничение времени на тесте 2
|
1000 мс
|
0 КБ
|
2024-07-25 08:45:58 |
2024-07-25 08:45:58 |
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(x,a,b) for(int x = a ; x <= b ; x++)
void solve(){
int n ; cin >> n;
bitset<200005>bs; cin >> bs;
int l = 0 , r = 0 , last = 0;
while(l < n)
{
if(r >= n)
{
l++;
cout << -1 << ' ';
continue;
}
while(bs[r] == 1 && r < n) r++;
if(r < n)
{
int ans = r - l + last;
last = ans;
cout << ans << ' ';
bs[r] = 1;
bs[l] = 0;
}
else cout << -1 << ' ';
l++;
if(r<l)r++;
}
cout << '\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t = 1 ; cin >> t ;
while(t--) solve();
}
Время: ? ms, память: ? КБ