Submission #497125

#TimeUsernameProblemLanguageResultExecution timeMemory
497125Abrar_Al_SamitSet (COCI21_set)C++17
40 / 110
1085 ms47384 KiB
#include<bits/stdc++.h> using namespace std; int add[2200][2200]; void PlayGround() { int n, k; cin >> n >> k; vector <int> v(n); vector <string> str(n); map<int,int>have; for(int i=0; i<n; ++i) { string s; cin >> s; str[i] = s; int num = 0; for(int j=0; j<k; ++j) { int d = s[j]-'0'; if(d&1) num += 1<<(j*2); if(d&2) num += 1<<(j*2+1); } v[i] = num; have[num] = 1; } for(int i=0; i<n; ++i) { for(int j=0; j<n; ++j) { int more = 0; for(int id=0; id<k; ++id) if(str[i][id]==str[j][id]) { int d = str[i][id]-'0'; if(d&1) more += 1<<(id*2); if(d&2) more += 1<<(id*2+1); } add[i][j] = more; } } long long ans = 0; for(int i=0; i<n; ++i) { for(int j=0; j<n; ++j) if(i!=j) { int req = (v[i]^v[j]) + add[i][j]; if(have.count(req)) ++ans; } } ans /= 6; cout << ans << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); PlayGround(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...