# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96573 | allllekssssa | Parametriziran (COCI19_parametriziran) | C++11 | 1491 ms | 6784 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;
#define pb push_back
const int maxi=50000+10;
int n,m;
string s[maxi];
vector<string> v[maxi];
map<string, int> mp;
long long merge(int m1, int m2)
{
long long ans=0;
mp.clear();
for (string str:v[m1])
{
string p = "";
for (int j=0;j<m;j++)
if ((1<<j)&m1 && (1<<j)&m2)
p+=str[j];
mp[p]++;
}
for (string str:v[m2])
{
string p = "";
for (int j=0;j<m;j++)
if ((1<<j)&m1 && (1<<j)&m2)
p+=str[j];
ans+=mp[p];
}
return ans;
}
int main()
{
cin>>n>>m;
long long ans = 0;
for (int i=1;i<=n;i++)
{
cin>>s[i];
int val = 0;
for (int j=0;j<m;j++)
if (s[i][j]!='?')
val+=1<<j;
v[val].pb(s[i]);
}
for (int i=0;i<(1<<m);i++)
{
for (int j=0;j<(1<<m);j++)
ans+= merge(i,j);
}
ans-=n;
cout<<ans/2<<endl;
return 0;
}
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... |