Submission #856472

#TimeUsernameProblemLanguageResultExecution timeMemory
856472MilosMilutinovicPIN (CEOI10_pin)C++14
60 / 100
346 ms14768 KiB
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define mp make_pair using namespace std; typedef long long ll; typedef pair<int,int> pii; int readint(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,d; char s[50005][4]; int main(){ scanf("%d%d",&n,&d); d=4-d; for(int i=1;i<=n;i++) scanf("%s",s+i); map<string,int> cnt; long long ans=0; for(int i=1;i<=n;i++){ for(int mask=(1<<4)-1;mask>=0;mask--){ int pc=__builtin_popcount(mask); if(pc<d) continue; string str=""; for(int j=0;j<4;j++) if(mask>>j&1) str+=s[i][j]; else str+='*'; ans+=cnt[str]*(d%2==pc%2?1:-1); } for(int mask=0;mask<(1<<4);mask++){ string str=""; for(int j=0;j<4;j++) if(mask>>j&1) str+=s[i][j]; else str+='*'; cnt[str]+=1; } } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

pin.cpp: In function 'int main()':
pin.cpp:25:32: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[4]' [-Wformat=]
   25 |  for(int i=1;i<=n;i++) scanf("%s",s+i);
      |                               ~^  ~~~
      |                                |   |
      |                                |   char (*)[4]
      |                                char*
pin.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d%d",&n,&d); d=4-d;
      |  ~~~~~^~~~~~~~~~~~~~
pin.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  for(int i=1;i<=n;i++) scanf("%s",s+i);
      |                        ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...