| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1322927 | yesimazix | PIN (CEOI10_pin) | C++20 | 25 ms | 8748 KiB |
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz size()
#define yes "YES"
#define no "NO"
#define IOI ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define pf push_front
#define mkp make_pair
#define S second
#define F first
using namespace std;
void freeopen () {
freopen("A.in", "r", stdin);
freopen("A.out", "w", stdout);
}
const int N = 2e5 + 10;
const int NN = 1e5 + 5;
const int Mod = 1e9 + 7;
const ll inf = 1e18;
const double pi = 3.14159265358979323846;
ll mod (ll x) {
return (x % Mod + Mod) % Mod;
}
ll bp(ll a, int b) {
ll res = 1;
while(b) {
if (b % 2) {
res = mod(res * a);
}
a = mod(a * a);
b >>= 1LL;
}
return res;
}
ll gcd(ll a, ll b){
while(b) {
a %= b;
swap(a, b);
}
return a;
}
ll lcm(ll a, ll b){
return a / gcd(a, b) * b;
}
void legenda_ne_umret() {
int n, k, ans =0;
cin >> n >> k;
string s[n];
unordered_map<string, int> cnt;
if (k == 4) {
for (int i = 0; i < n; i++) {
cin >> s[i];
ans += max(0ll, (i) - cnt[s[i]]);
cnt[s[i]]++;
}
cout << ans;
return;
}
for (int i = 0; i < n; i++) {
cin >> s[i];
for (int mask = 0; mask < (1 << 4); mask++) {
if (__builtin_popcount(mask) != k) continue;
string ss = s[i];
for (int bit = 0; bit < 4; bit++) {
if ((mask >> bit) & 1) {
ss[bit] = '?';
}
}
ans += cnt[ss];
}
for (int mask = 0; mask < (1 << 4); mask++) {
if (__builtin_popcount(mask) != k) continue;
string ss = s[i];
for (int bit = 0; bit < 4; bit++) {
if ((mask >> bit) & 1) {
ss[bit] = '?';
}
}
cnt[ss]++;
}
}
cout << ans;
}
signed main() {
IOI;
// freeopen();
///////////////////////////////////////////
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "Case " << i << ": ";
legenda_ne_umret();
cout << '\n';
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
