# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
496425 | XBoRickie | PIN (CEOI10_pin) | C++14 | 199 ms | 11668 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;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;
#define fastIO ios::sync_with_stdio(false), cin.tie(NULL)
#define forw(i, l, r) for( int i = (l) ; i < (r) ; i++ )
#define forb(i, r, l) for( int i = (r) ; i >= (l) ; i-- )
#define log2i(x) (64 - __builtin_clzll(1ll * (x)) - 1)
#define numBit(x) (__builtin_popcountll(1ll * (x)))
#define getBit(x, i) ((x) >> (i) & 1)
#define Pi acos(-1.0l)
#define sz(x) int(x.size())
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define debug(x) cerr << #x << " = " << x << '\n';
const int N = 50007;
const int base = 311;
int n, d;
int comb[5][5];
map<ll, int> cnt[16];
int main() {
fastIO;
comb[0][0] = 1;
forw(i, 1, 5) forw(j, 0, i + 1) {
comb[i][j] = comb[i - 1][j];
if(j) comb[i][j] += comb[i - 1][j - 1];
}
cin >> n >> d; d = 4 - d;
forw(i, 0, n) {
string st; cin >> st;
forw(j, 0, 16) {
ll sum = 0;
forw(k, 0, 4) if(getBit(j, k)) sum = sum * base + st[k];
cnt[j][sum]++;
}
}
ll ans = 0;
forw(i, 0, 16) {
if(numBit(i) < d) continue;
ll val = 0;
for(auto x:cnt[i]) val += x.se * (x.se - 1) / 2;
val *= comb[numBit(i)][numBit(i) - d];
if((numBit(i) - d) & 1) ans -= val;
else ans += val;
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |