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 FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl
typedef long long ll;
typedef pair<int, int> point;
const int MAXN = 5e4 + 5;
int n, m;
string s[MAXN];
bitset<MAXN> bit[8][28];
bitset<MAXN> pun;
void ukloni(int x){
pun.set(x, 0);
REP(j, m){
if(s[x][j] == '?'){
REP(k, 26)
bit[j][k].set(x, 0);
}
else
bit[j][ s[x][j] - 'a' ].set(x, 0);
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m;
REP(i, n)
cin >> s[i];
REP(i, n)
pun.set(i);
REP(i, n)
REP(j, m){
if(s[i][j] == '?'){
REP(k, 26)
bit[j][k].set(i);
}
else
bit[j][ s[i][j] - 'a' ].set(i);
}
ll sol = 0;
REP(i, n){
bitset<MAXN> bits; bits.reset();
ukloni(i);
if(s[i][0] == '?')
bits |= pun;
else
bits = bit[0][ s[i][0] - 'a' ];
FOR(j, 1, m){
if(s[i][j] == '?') continue;
bits &= bit[j][ s[i][j] - 'a' ];
}
sol += bits.count();
}
cout << sol;
}
# | 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... |