Submission #232794

#TimeUsernameProblemLanguageResultExecution timeMemory
232794VimmerParametriziran (COCI19_parametriziran)C++14
110 / 110
857 ms5228 KiB
#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 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...