Submission #232794

# Submission time Handle Problem Language Result Execution time Memory
232794 2020-05-18T07:05:44 Z Vimmer Parametriziran (COCI19_parametriziran) C++14
110 / 110
857 ms 5228 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>



//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")

#define sz(x) ll(x.size())
#define N 500015
#define base 1000000
#define M ll(1e9+7)
#define F first
#define S second
#define pb push_back
#define in insert
#define eb emplace_back
#define ed "\n"

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef short int si;

//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

map <string, vector <string> > a;

map <string, int> mp;

int main()
{
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m;

    cin >> n >> m;

    vector <string> vr; vr.clear();

    for (int i = 0; i < n; i++)
    {
        string s;

        cin >> s;

        string str = "";

        for (int j = 0; j < m; j++)
            if (s[j] == '?') str += '0'; else str += '1';

        a[str].pb(s);

        if (sz(a[str]) == 1) vr.pb(str);
    }

    ll ans = 0;

    for (auto it : vr)
    {
        vector <string> g = a[it];

        mp.clear();

        for (auto itr : g)
        {
            ans += ll(mp[itr]);

            mp[itr]++;
        }
    }

    for (int i = 0; i < sz(vr); i++)
        for(int j = i + 1; j < sz(vr); j++)
        {
            mp.clear();

            string str = "";

            for (int u = 0; u < m; u++)
              if (vr[i][u] == '0' || vr[j][u] == '0') str += '0';
                else str += '1';

            vector <string> g = a[vr[i]];

            for (auto it : g)
            {
                string s = it;

                for (int j = 0; j < m; j++)
                    if (str[j] == '0') s[j] = '?';

                mp[s]++;
            }

            g = a[vr[j]];

            for (auto it : g)
            {
                string s = it;

                for (int j = 0; j < m; j++)
                    if (str[j] == '0') s[j] = '?';

                ans += mp[s];
            }
        }

    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 3700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2172 KB Output is correct
2 Correct 19 ms 2124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2636 KB Output is correct
2 Correct 35 ms 3716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2684 KB Output is correct
2 Correct 32 ms 2040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 3012 KB Output is correct
2 Correct 53 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 163 ms 5228 KB Output is correct
2 Correct 69 ms 2596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 255 ms 2728 KB Output is correct
2 Correct 80 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 344 ms 5012 KB Output is correct
2 Correct 234 ms 3180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 548 ms 3296 KB Output is correct
2 Correct 129 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 857 ms 4316 KB Output is correct
2 Correct 567 ms 3276 KB Output is correct