Submission #96689

# Submission time Handle Problem Language Result Execution time Memory
96689 2019-02-10T23:34:07 Z Shtef Parametriziran (COCI19_parametriziran) C++14
0 / 110
727 ms 5656 KB
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

int n, m;
string s[50005];
vector <string> a[(1 << 7) + 5];
ll sol;

ll processmaskpair(int x, int y){
	map <string, ll> c;
	for(vector <string>::iterator i = a[x].begin() ; i != a[x].end() ; ++i){
		string o = *i;
		string t = "";
		for(int j = 0 ; j < m ; ++j){
			if((x & (1 << j)) && (y & (1 << j))){
				t += o[j];
			}
		}
		c[t]++;
	}
	ll ret = 0;
	for(vector <string>::iterator i = a[y].begin() ; i != a[y].end() ; ++i){
		string o = *i;
		string t = "";
		for(int j = 0 ; j < m ; ++j){
			if((x & (1 << j)) && (y & (1 << j))){
				t += o[j];
			}
		}
		ret += c[t];
	}
	return ret;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 0 ; i < n ; ++i){
	cin >> s[i];
}
for(int i = 0 ; i < n ; ++i){
	int mask = 0;
	for(int j = 0 ; j < m ; ++j){
		if(s[i][j] != '?'){
			mask |= (1 << j);
		}
	}
	a[mask].push_back(s[i]);
}
for(int i = 0 ; i < (1 << m) ; ++i){
	for(int j = 0 ; j <= i ; ++j){
		sol += processmaskpair(i, j);
	}
}
sol -= n;
cout << sol << endl;

return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 4072 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 3308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 3304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 3712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 4016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 157 ms 5656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 188 ms 3832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 313 ms 5488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 488 ms 4208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 727 ms 5108 KB Output isn't correct
2 Halted 0 ms 0 KB -