Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("Ofast,no-stack-protector")
- #include<bits/stdc++.h>
- //#define int long long
- #define quick ios::sync_with_stdio(0);cin.tie(0);
- #define rep(x,a,b) for(int x=a;x<=b;x++)
- #define repd(x,a,b) for(int x=a;x>=b;x--)
- #define F first
- #define S second
- #define all(x) x.begin(),x.end()
- #define mp make_pair
- #define eb emplace_back
- #define sz(x) (int)(x.size())
- #define lowbit(x) (x&-x)
- using namespace std;
- typedef pair<int,int> pii;
- typedef complex<int> P;
- #define X real()
- #define Y imag()
- void debug(){
- cout<<"\n";
- }
- template<class T,class ...U>
- void debug(T a,U ...b){
- cout<<a<<" ",debug(b...);
- }
- const int N=2e5+7;
- const int INF=1e18;
- bool p1(const string&v1,const string&v2){
- unordered_map<char,bool> m;
- for(char i:v1) m[i]=true;
- for(char i:v2){
- if(m.count(i)) return false;
- }
- return true;
- }
- bool p2(const string&v1,const string&v2){
- if(sz(v1)==sz(v2)) return false;
- unordered_map<char,bool> m;
- for(char i:v2) m[i]=true;
- for(char i:v1){
- if(!m.count(i)) return false;
- }
- return true;
- }
- bool p3(const string&v1,const string&v2){
- return p2(v2,v1);
- }
- bool eq(const string&v1,const string&v2){
- if(sz(v1)!=sz(v2)) return false;
- unordered_map<char,bool> m;
- for(char i:v2) m[i]=true;
- for(char i:v1){
- if(!m.count(i)) return false;
- }
- return true;
- }
- bool p4(const string&v1,const string&v2){
- return !p1(v1,v2)&&!p2(v1,v2)&&!p3(v1,v2)&&!eq(v1,v2);
- }
- string s[N];
- int cntp5(const string&x,int n){
- int l=sz(x);
- rep(i,0,n-1){
- rep(j,i+1,n-1){
- if(p4(s[i],s[j])){
- return 0;
- }
- }
- }
- int ans=0;
- rep(S,0,(1<<l)-1){
- string x1;
- string x2;
- rep(i,0,l-1){
- if((1<<i)&S) x1+=x[i];
- else x2+=x[i];
- }
- ans++;
- rep(i,0,n-1){
- if(p4(x1,s[i])||p4(x2,s[i])){
- ans--;break;
- }
- }
- }
- return ans;
- }
- signed main(){
- quick
- int n;
- cin>>n;
- string x;
- cin>>x;
- rep(i,0,n-1){
- cin>>s[i];
- }
- int P1,P2,P3,P4;
- P1=P2=P3=P4=0;
- rep(i,0,n-1){
- P1+=p1(s[i],x);
- P2+=p2(x,s[i]);
- P3+=p3(x,s[i]);
- P4+=p4(s[i],x);
- }
- cout<<P1<<" "<<P2<<" "<<P3<<" "<<P4<<" "<<cntp5(x,n)<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement