답안 #224802

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224802 2020-04-18T21:05:38 Z MKopchev PIN (CEOI10_pin) C++14
100 / 100
605 ms 20472 KB
#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

pin.cpp: In function 'int main()':
pin.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i",&n,&want);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1280 KB Output is correct
2 Correct 18 ms 1280 KB Output is correct
3 Correct 15 ms 1024 KB Output is correct
4 Correct 183 ms 4600 KB Output is correct
5 Correct 234 ms 5112 KB Output is correct
6 Correct 211 ms 5112 KB Output is correct
7 Correct 170 ms 4600 KB Output is correct
8 Correct 237 ms 5536 KB Output is correct
9 Correct 403 ms 7544 KB Output is correct
10 Correct 433 ms 7956 KB Output is correct
11 Correct 229 ms 5240 KB Output is correct
12 Correct 402 ms 7672 KB Output is correct
13 Correct 253 ms 5752 KB Output is correct
14 Correct 233 ms 5496 KB Output is correct
15 Correct 413 ms 7876 KB Output is correct
16 Correct 393 ms 15608 KB Output is correct
17 Correct 605 ms 20472 KB Output is correct
18 Correct 579 ms 17016 KB Output is correct
19 Correct 541 ms 18936 KB Output is correct
20 Correct 598 ms 20472 KB Output is correct