Submission #878940

#TimeUsernameProblemLanguageResultExecution timeMemory
878940Yahia_EmaraSet (COCI21_set)C++17
40 / 110
58 ms4700 KiB
#include <bits/stdc++.h> #define pb push_back #define ctoi(x) int(x-'0') #define cdv(x,y) (((x)+(y)-1)/(y)) #define LOOP(n) for(int rp=0;rp<(n);rp++) #define sz(x) int(x.size()) #define dbg(x) cout << (#x) << " : " << x << endl; #define sq(x) ((x)*(x)) #define fs first #define sc second using namespace std; typedef long long ll; typedef long double dl; const int SZ=6e5+7,MSZ=1e7+7; const ll INF=1e18+7; int a[SZ],ans=0; bitset<MSZ>bt(0); int n,k; int xor3(int x,int y){ int z=0,p=1; LOOP(k){ z+=(3-(x%10+y%10)%3)*p; p*=10,x/=10,y/=10; } return z; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int tt=1; //cin >> tt; LOOP(tt){ cin >> n >> k; for(int i=0;i<n;i++){ cin >> a[i];bt[a[i]]=1; } int c=0; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ c+=bt[xor3(a[i],a[j])]; } } cout << c/3; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...