Submission #571788

# Submission time Handle Problem Language Result Execution time Memory
571788 2022-06-02T18:00:42 Z Blagojce PIN (CEOI10_pin) C++11
0 / 100
313 ms 18556 KB
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define st first
#define nd second 
#define all(x) begin(x), end(x)
#define pb push_back
#define all(x) begin(x), end(x)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int mxn = 1e5+5;
const ll inf = 1e18;
const ld eps = 1e-13;
const ll mod = 1e9 + 9;

mt19937 _rand(time(0));

int n, k;
string s[mxn];
unordered_map<string, int> mapa;

ll ans = 0;
void process(int j){
	fr(mask, 1, (1<<4)){
		int bts = __builtin_popcount(mask);
		if(bts < k) continue;
		string ns = "$$$$";
		fr(i, 0, 4){
			if(mask&(1<<i)){
				ns[i] = s[j][i];
			}
		}
		int p = +1;
		if((bts-k)%2){
			 p = -1;
		}
		ans += mapa[ns]*p;
	}
	fr(mask, 1, (1<<4)){
		string ns = s[j];
		fr(i, 0, 4){
			if(mask&(1<<i)) continue;
			ns[i] = '$';
		}
		mapa[ns] ++;
	}
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	fr(i, 0, n){
		cin >> s[i];
	
	}
	k = n-k;
	
	fr(i, 0, n)process(i);
	if(k == 4){
		cout<<ans<<endl;
		return 0;
	}
	
	int ans2 = ans;
	
	
	ans = 0;
	mapa.clear();
	k++;
	fr(i, 0, n)process(i);
	
	
	
	cout<<ans2-ans<<endl;
	return 0;
	
}/*
1
3
2 3 -1*/
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4096 KB Output isn't correct
2 Incorrect 7 ms 4052 KB Output isn't correct
3 Incorrect 6 ms 3976 KB Output isn't correct
4 Incorrect 55 ms 6232 KB Output isn't correct
5 Incorrect 66 ms 7160 KB Output isn't correct
6 Incorrect 63 ms 7112 KB Output isn't correct
7 Incorrect 59 ms 6248 KB Output isn't correct
8 Incorrect 91 ms 7212 KB Output isn't correct
9 Incorrect 123 ms 8204 KB Output isn't correct
10 Incorrect 126 ms 8528 KB Output isn't correct
11 Incorrect 70 ms 7192 KB Output isn't correct
12 Incorrect 124 ms 8372 KB Output isn't correct
13 Incorrect 90 ms 7284 KB Output isn't correct
14 Incorrect 69 ms 7196 KB Output isn't correct
15 Incorrect 133 ms 8408 KB Output isn't correct
16 Incorrect 160 ms 13576 KB Output isn't correct
17 Incorrect 313 ms 18524 KB Output isn't correct
18 Incorrect 184 ms 14332 KB Output isn't correct
19 Incorrect 213 ms 15580 KB Output isn't correct
20 Incorrect 268 ms 18556 KB Output isn't correct