이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |