Submission #917410

#TimeUsernameProblemLanguageResultExecution timeMemory
917410PM1PIN (CEOI10_pin)C++17
100 / 100
290 ms16372 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxn=5e4+5; int n,d; string s[mxn]; map<vector<char>,int>mp[(1<<4)]; ll ans[4]; int main(){ cin>>n>>d; for(int i=1;i<=n;i++){ cin>>s[i]; for(int j=0;j<(1<<4)-1;j++){ int cnt=0; vector<char>v; for(int k=0;k<4;k++){ if(j&(1<<k)){ cnt++; v.push_back(s[i][k]); } } ans[3-cnt]+=mp[j][v]; mp[j][v]++; //cout<<j<<" "<<mp[j][v]<<endl; }//cout<<endl; } ans[1]-=(ans[0]*3); ans[2]-=(ans[1]*2+ans[0]*3); ans[3]-=ans[1]+ans[2]+ans[0]; cout<<ans[d-1]<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...