# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104580 | Hassoony | Parametriziran (COCI19_parametriziran) | C++17 | 804 ms | 3920 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(1e9+7);
const ll inf=(1ll<<61);
const int MX=50009;
int n,m;
vector<string>v[(1<<7)];
string s;
unordered_map<string,int>vis;
char oo[8];
ll ans=0;
void add(string s){
int ret=0;
string tmp="";
for(int j=0;j<m;j++){
if(s[j]!='?')ret+=(1<<j);
}
v[ret].push_back(s);
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++){
scanf("%s",&oo);s=oo;
add(s);
}
for(int i1=0;i1<(1<<m);i1++){
for(int j1=0;j1<(1<<m);j1++){
int mask1=i1,mask2=j1;
vis.clear();
for(auto pp:v[mask1]){
string tmp="";
for(int j=0;j<m;j++){
if((mask1&(1<<j))&&(mask2&(1<<j)))tmp+=pp[j];
}
vis[tmp]++;
}
for(auto pp:v[mask2]){
string tmp="";
for(int j=0;j<m;j++){
if((mask1&(1<<j))&&(mask2&(1<<j)))tmp+=pp[j];
}
ans+=vis[tmp];
}
}
}
cout<<(ans-n)/2<<endl;
}
/*
3 3
??b
c??
c?c
4 6
ab??c?
??kll?
a?k??c
?bcd??
5 2
??
b?
c?
?g
cg
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |