#include <bits/stdc++.h>
using namespace std ;
const int MAX = 1000000 ;
int arr[MAX] ;
int main()
{
int n , k ;
cin>>n>>k ;
string s ;
cin>>s ;
int cnt = 0 ;
vector<int>v ;
vector< vector<int> >ans ;
for(int i = 0 ; i < n ; ++i)
{
v.push_back(i) ;
if(s[i] == 'b')
arr[cnt]++ ;
else if(s[i] == 'c')
cnt++ ;
if(cnt == 0)
continue ;
if(arr[cnt] + arr[cnt-1] == k)
{
int s = v.size()-k-1 ;
vector<int>tmp ;
for(int j = s ; j <= s+k ; ++j)
tmp.push_back(v[j]) ;
for(int j = 0 ; j < k+1 ; ++j)
v.pop_back() ;
ans.push_back(tmp) ;
arr[cnt] = 0 ;
--cnt ;
arr[cnt] = 0 ;
}
}
reverse(ans.begin() , ans.end()) ;
for(int i = 0 ; i < n / (k+1) ; ++i)
{
for(int j = 0 ; j < k+1 ; ++j)
cout<<ans[i][j]+1<<" ";
cout<<"\n";
}
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Runtime error |
4 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Runtime error |
6 ms |
612 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
19 ms |
3104 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
41 ms |
5628 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
55 ms |
7428 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
113 ms |
10968 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
58 ms |
12492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |