Submission #496459

# Submission time Handle Problem Language Result Execution time Memory
496459 2021-12-21T08:37:00 Z LptN21 PIN (CEOI10_pin) C++14
75 / 100
30 ms 15204 KB
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define PI acos(-1.0)
#define eps 1e-9
#define FF first
#define SS second
// VECTOR (6)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define uniq(v) sort(all( (v) )), (v).resize( unique(all( (v) )) - (v).begin() );
// BIT (6)
#define CNTBIT(x) __builtin_popcountll(x)
#define ODDBIT(x) __builtin_parityll(x)
#define MASK(i) (1LL<<(i))
#define BIT(x, i) (((x)>>(i))&1)
#define SUBSET(big, small) (((big)&(small))==(small))
#define MINBIT(x) (x)&(-x)
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;
/* CODE BELOW */
const int N = 5e4 + 7, M = 4;
const ll oo = 1e18 + 7;
const int MOD = 1e9 + 7;

int n, m, k, t;

const int BASE = 37;

int pw[M]{1};
int a[N][M];

const int MX = 1874161 + 7;

int cnt[MX];
int bit[MX];

int getv(char c) {
    if('0' <= c && c <= '9') return c - '0' + 1;
    return c - 'a' + 12;
}

signed main() {
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);
    //fastIO;
    scanf("%d%d\n", &n, &m); char ch[M];

    for(int i=1;i<=n;i++) {
        scanf("%s\n", &ch);
        for(int j=0;j<M;j++) {
            a[i][j] = getv(ch[j]);
        }
        for(int j=0;j<MASK(M);j++) {
            int hs = 0, _cnt = 0;
            for(int l=0;l<M;l++) {
                hs= hs*BASE + a[i][l]*BIT(j, l);
                _cnt+=BIT(j, l);
            }
            cnt[hs]++, bit[hs] = _cnt;
        }
    }

    ll ans[M+1]; memset(ans, 0, sizeof ans);
    for(int i=0;i<MX;i++) if(cnt[i]) {
        ans[bit[i]]+= 1LL*cnt[i]*(cnt[i]-1)/2;
    }

    ans[3]-= ans[4];
    ans[2]-= 3*ans[3] + 6*ans[4];
    ans[1]-= 2*ans[2] + 3*ans[3] + 4*ans[4];
    ans[0]-= ans[1] + ans[2] + ans[3] + ans[4];
    printf("%lld", ans[M-m]);

    return 0;
}

Compilation message

pin.cpp: In function 'int main()':
pin.cpp:56:17: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[4]' [-Wformat=]
   56 |         scanf("%s\n", &ch);
      |                ~^     ~~~
      |                 |     |
      |                 char* char (*)[4]
pin.cpp:53:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |     scanf("%d%d\n", &n, &m); char ch[M];
      |     ~~~~~^~~~~~~~~~~~~~~~~~
pin.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         scanf("%s\n", &ch);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3404 KB Output is correct
2 Correct 4 ms 3404 KB Output is correct
3 Correct 7 ms 3404 KB Output is correct
4 Correct 11 ms 3788 KB Output is correct
5 Correct 17 ms 3844 KB Output is correct
6 Correct 14 ms 3876 KB Output is correct
7 Correct 11 ms 3792 KB Output is correct
8 Correct 11 ms 3788 KB Output is correct
9 Correct 15 ms 4080 KB Output is correct
10 Correct 16 ms 4260 KB Output is correct
11 Correct 11 ms 3904 KB Output is correct
12 Correct 15 ms 4104 KB Output is correct
13 Correct 11 ms 3916 KB Output is correct
14 Correct 15 ms 3788 KB Output is correct
15 Correct 17 ms 4220 KB Output is correct
16 Incorrect 24 ms 15028 KB Output isn't correct
17 Incorrect 29 ms 15204 KB Output isn't correct
18 Incorrect 21 ms 15052 KB Output isn't correct
19 Incorrect 29 ms 15104 KB Output isn't correct
20 Incorrect 30 ms 15172 KB Output isn't correct