Submission #156644

#TimeUsernameProblemLanguageResultExecution timeMemory
156644IvanCParametriziran (COCI19_parametriziran)C++17
110 / 110
1892 ms56884 KiB
#include <bits/stdc++.h> using namespace std; typedef tuple<char,char,char,char,char,char> sexta; map<sexta, int> dicio; long long total; string original; int M, N; inline sexta set_pos(sexta s, int pos, char c){ if(pos == 0){ return make_tuple(c, get<1>(s), get<2>(s), get<3>(s), get<4>(s), get<5>(s)); } else if(pos == 1){ return make_tuple(get<0>(s), c, get<2>(s), get<3>(s), get<4>(s), get<5>(s)); } else if(pos == 2){ return make_tuple(get<0>(s), get<1>(s), c, get<3>(s), get<4>(s), get<5>(s)); } else if(pos == 3){ return make_tuple(get<0>(s), get<1>(s), get<2>(s), c, get<4>(s), get<5>(s)); } else if(pos == 4){ return make_tuple(get<0>(s), get<1>(s), get<2>(s), get<3>(s), c, get<5>(s)); } else if(pos == 5){ return make_tuple(get<0>(s), get<1>(s), get<2>(s), get<3>(s), get<4>(s), c); } return s; } void brute_insert(int pos, sexta davez){ if(pos == M){ //cout << "Original: " << original << " Davez: " << davez << endl; dicio[davez]++; return; } if(original[pos] != '?'){ brute_insert(pos+1, set_pos(davez, pos, original[pos])); brute_insert(pos+1, set_pos(davez, pos, '?')); } else{ brute_insert(pos+1, set_pos(davez, pos, '!')); } } void brute_count(int pos, sexta davez){ if(pos == M){ //cout << "Original: " << original << " Davez: " << davez << endl; if(dicio.count(davez)) total += dicio[davez]; return; } brute_count(pos+1, set_pos(davez, pos, original[pos])); brute_count(pos+1, set_pos(davez, pos, '!')); } int main(){ sexta vazia = make_tuple('0', '0', '0', '0', '0', '0'); cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); cin >> N >> M; for(int i = 0; i < N; i++){ cin >> original; brute_count(0, vazia); brute_insert(0, vazia); } cout << total << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...