제출 #862242

#제출 시각아이디문제언어결과실행 시간메모리
862242AbdelmagedNourSet (COCI21_set)C++17
40 / 110
1040 ms6492 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; typedef long long ll; ll cnt[1<<25]; int a[600005],n,k; int Xor(int a,int b){ int res=0; for(int i=0;i<k;i++){ int f=(a>>(i*2))&3,s=(b>>(i*2))&3; res+=((12-(f+s))%3)<<(2*i); } return res; } int convert(string s){ int res=0; for(int i=0;i<k;i++){ res+=(s[i]-'1')<<(2*i); } return res; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k; ll res=0; for(int i=0;i<n;i++){ string s; cin>>s; a[i]=convert(s); res+=cnt[a[i]]; for(int j=0;j<i;j++)cnt[Xor(a[i],a[j])]++; } cout<<res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...