1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <bits/stdc++.h>
using namespace std;

vector <map <vector <bool>, bool> > mapa;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	
	vector <vector <bool> > seq(n);
	
	for(int i=0; i<n; ++i)
	{
		string s;
		cin>>s;
		
		for(int j=0; j<(int)s.length(); ++j)
		{
			if(s[j]=='L')
				seq[i].push_back(0);
			else
				seq[i].push_back(1);
		}
	}
	
	for(int i=0; i<n; ++i)
	{
		for(int j=0; j<n; ++j)
		{
			vector <bool> v=seq[i];
			for(bool b : seq[j])
				v.push_back(b);
			
			mapa.clear();
			mapa.push_back({});
			
			for(bool b : v)
			{
				int d=(int)mapa.size();
				if(b==0)
				{
					mapa.push_back({});
					
					for(int nr=d-1; nr>=0; --nr)
					{
						for(pair <vector <bool>, bool> s : mapa[nr])
						{
							vector <bool> s2=s.first;
							s2.push_back(0);
							mapa[nr+1][s2]=1;
						}
					}
					
					vector <bool> temp={0};
					mapa[1][temp]=1;
				}
				else
				{
					for(int nr=1; nr<d; ++nr)
					{
						for(pair <vector <bool>, bool> s : mapa[nr])
						{
							vector <bool> s2=s.first;
							s2.push_back(1);
							mapa[nr-1][s2]=1;
						}
					}
				}
			}
			
			/*int d=(int)mapa.size();
			for(int nr=0; nr<d; ++nr)
			{
				for(pair <vector <bool>, bool> p : mapa[nr])
				{
					for(bool b : p.first)
						cout<<b<<" ";
					cout<<"\n";
				}
			}
			cout<<"\n";*/
			
			cout<<mapa[0].size()<<" ";
		}
		cout<<"\n";
	}
	return 0;
}