# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97391 | Mercenary | Parametriziran (COCI19_parametriziran) | C++11 | 687 ms | 3696 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 taskname "TEST"
#define pb push_back
typedef long double ld;
typedef long long ll;
const int maxn = 5e4 + 5;
int n , m;
vector<string> v[1 << 6];
ll res = 0;
int Cal(int x , int y)
{
vector<string> t;
t.reserve(v[x].size());
for(auto c : v[x])
{
string tmp;
for(int j = 0 ; j < m ; ++j)
if(((x >> j) & 1) && ((y >> j) & 1))tmp.pb(c[j]);
t.pb(tmp);
}
sort(t.begin(),t.end());
for(auto c : v[y])
{
string tmp;
for(int j = 0 ; j < m ; ++j)
if(((x >> j) & 1) && ((y >> j) & 1))tmp.pb(c[j]);
res += upper_bound(t.begin(),t.end(),tmp) - lower_bound(t.begin(),t.end(),tmp);
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if(fopen(taskname".INP","r"))
freopen(taskname".INP", "r",stdin) ,
freopen(taskname".OUT", "w",stdout);
cin >> n >> m;
for(int i = 1 ; i <= n ; ++i){
string s;
cin >> s;
int key = 0;
for(int j = 0 ; j < m ; ++j)
if(s[j] != '?')key |= (1 << j);
v[key].pb(s);
}
for(int i = 0 ; i < (1 << m) ; ++i)
for(int j = i ; j < (1 << m) ; ++j)
res += Cal(i , j);
res -= n;
cout << res;
}
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... |