# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224802 | MKopchev | PIN (CEOI10_pin) | C++14 | 605 ms | 20472 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int hsh(char c)
{
if('0'<=c&&c<='9')return c-'0';
return c-'a'+10;
}
bool valid(char c)
{
if('0'<=c&&c<='9')return 1;
if('a'<=c&&c<='z')return 1;
return 0;
}
const int nmax=5e4+42;
vector<int> in;
long long output[5];
map< vector<int>, int> seen;
int n,want;
int main()
{
scanf("%i%i",&n,&want);
for(int i=1;i<=n;i++)
{
in={};
for(int j=1;j<=4;j++)
{
char c=getchar();
while(valid(c)==0)c=getchar();
int val=hsh(c);
in.push_back(val);
}
for(int mask=0;mask<(1<<4);mask++)
{
int other=0;
vector<int> help={};
for(int j=0;j<4;j++)
if((mask&(1<<j)))help.push_back(in[j]);
else {help.push_back(-1);other++;}
output[other]+=seen[help];
seen[help]++;
}
}
//cout<<output[0]<<" "<<output[1]<<" "<<output[2]<<" "<<output[3]<<" "<<output[4]<<endl;
output[2]=output[2]-3*output[1];
output[3]=output[3]-3*output[1]-2*output[2];
output[4]=1LL*n*(n-1)/2-output[0]-output[1]-output[2]-output[3];
//cout<<output[0]<<" "<<output[1]<<" "<<output[2]<<" "<<output[3]<<" "<<output[4]<<endl;
printf("%lld\n",output[want]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |