Submission #1322869

#TimeUsernameProblemLanguageResultExecution timeMemory
1322869yesimazixPIN (CEOI10_pin)C++20
30 / 100
26 ms8748 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;
    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] = '?';
                }
            }
            // cout << "COL " << ss << " -> " << cnt[ss] << '\n';
            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 << ss << ' ' << cnt[ss] << '\n';
        }
    }
    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)

pin.cpp: In function 'void freeopen()':
pin.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen("A.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
pin.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen("A.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...