Skip to content

Commit 1af6c5e

Browse files
committed
Added 721A - One-dimensional Japanese Crossword.cpp
1 parent b3bf97d commit 1af6c5e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
// Code Written By: Vikash Patel
5+
6+
int main()
7+
{
8+
int n;
9+
cin>>n;
10+
string s;
11+
cin>>s;
12+
int c=0;
13+
int d=0;
14+
vector<int> ans;
15+
for(int i=0;i<n;i++)
16+
{
17+
if(s[i]=='B')
18+
{
19+
c++;
20+
d=0;
21+
for(int j=i;j<n;j++)
22+
{
23+
if(s[j]=='B')
24+
d++;
25+
else
26+
break;
27+
}
28+
i+=d;
29+
ans.push_back(d);
30+
}
31+
}
32+
cout<<c<<endl;
33+
for(auto i : ans)
34+
{
35+
cout<<i<<" ";
36+
}
37+
cout<<endl;
38+
}
39+
40+
41+
42+
43+
44+
45+
46+

0 commit comments

Comments
 (0)