Submission #336743

#TimeUsernameProblemLanguageResultExecution timeMemory
336743nandonathanielPIN (CEOI10_pin)C++14
30 / 100
615 ms14852 KiB
#include<bits/stdc++.h> using namespace std; map<string,int> mp[16]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); long long ans=0; string s; int n,d; cin >> n >> d; for(int it=1;it<=n;it++){ cin >> s; for(int mask=0;mask<(1<<4);mask++){ if(__builtin_popcount(mask)!=d)continue; string t=""; vector<int> v; bool ya[4]; memset(ya,false,sizeof(ya)); for(int i=0;i<4;i++){ if((1<<i) & mask)v.push_back(i); else{ t+=s[i]; ya[i]=true; } } ans+=mp[15-mask][t]; for(int i=1;i<(1<<v.size());i++){ for(int j=0;j<v.size();j++)ya[v[j]]=true; int msk=0; string k=""; for(int j=0;j<4;j++){ if(ya[j]){ msk+=(1<<j); k+=s[j]; } } if(__builtin_popcount(i)&1)ans-=mp[msk][k]; else ans+=mp[msk][k]; for(int j=0;j<v.size();j++)ya[v[j]]=false; } } for(int mask=0;mask<(1<<4);mask++){ string t=""; for(int i=0;i<4;i++){ if((1<<i) & mask)t+=s[i]; } mp[mask][t]++; } } cout << ans << '\n'; return 0; }

Compilation message (stderr)

pin.cpp: In function 'int main()':
pin.cpp:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int j=0;j<v.size();j++)ya[v[j]]=true;
      |                 ~^~~~~~~~~
pin.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int j=0;j<v.size();j++)ya[v[j]]=false;
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...