Submission #848829

# Submission time Handle Problem Language Result Execution time Memory
848829 2023-09-13T14:51:07 Z tfgs Parametriziran (COCI19_parametriziran) C++17
110 / 110
1244 ms 1752 KB
#include <bits/stdc++.h>
using namespace std;
using pll = pair<long long, long long>;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define eb emplace_back
#define vi vector<ll>
#define vb vector<bool>
#define f0(i,a) for(ll i=0;i<(a);i++)
#define f1(i,a) for(ll i=1;i<(a);i++)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define f first
#define s second
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html
template<class Fun> class y_combinator_result {
    Fun fun_;
public:
    template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
    template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); }
};
template<class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); }
#ifdef I_AM_NOOB
#define gg(...) [](const auto&...x){ char c='='; cerr<<#__VA_ARGS__; ((cerr<<exchange(c,',')<<x),...); cerr<<endl; }(__VA_ARGS__);
#else
#define gg(...) 777771449
#endif

constexpr ll INFF = 1e18;
constexpr ll P = 1e9+7;
// constexpr ll P = 998244353;
constexpr ll N = 5e4+5;

int main() {
    cin.tie(0) -> ios::sync_with_stdio(0);
    
    ll n, m; while (cin >> n >> m) {
        //idx, letter
        vector<vector<bitset<N>>> mask(m, vector<bitset<N>>(26));
        ll ans = 0;
        f0(i, n) {
            string s; cin >> s;
            bitset<N> res; res.set();
            f0(j, m) {
                ll c = s[j] - 'a';
                if (s[j] != '?') {
                    res &= mask[j][c];
                    mask[j][c].set(i);
                } else {
                    for (ll k = 0; k < 26; k++) mask[j][k].set(i);
                }
            }
            f0(j, i) {
                ans += res[j];
            }
        }

        cout << ans << endl;
    } 
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1206 ms 704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 439 ms 860 KB Output is correct
2 Correct 433 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 794 ms 896 KB Output is correct
2 Correct 1219 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 430 ms 1116 KB Output is correct
2 Correct 449 ms 1308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1139 ms 1124 KB Output is correct
2 Correct 248 ms 1208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1200 ms 1320 KB Output is correct
2 Correct 858 ms 1212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 635 ms 1632 KB Output is correct
2 Correct 449 ms 1428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 911 ms 1712 KB Output is correct
2 Correct 1076 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 567 ms 1636 KB Output is correct
2 Correct 503 ms 1716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1244 ms 1752 KB Output is correct
2 Correct 1218 ms 1648 KB Output is correct