Submission #1323259

#TimeUsernameProblemLanguageResultExecution timeMemory
1323259bekawxzPIN (CEOI10_pin)C++20
100 / 100
218 ms12132 KiB
/*
too fool to solve this problem
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define ll long long
using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll INF = LLONG_MAX;
const ll N = 2 * 100000 + 5;
const ll MOD = 1e9 + 7;
ll binpow(ll a,ll b){
	ll res = 1;
	while(b){
		if(b & 1){
			res *= a;
		}
		a *= a;
		b/=2;
	}
	return res;
}
void dumb_ass() {
	ll n,d;
	cin >> n >> d;
	vector<string> a(n);
	map<string,ll> mp[20];
	vector<ll> ans(20);
	for(ll i = 0;i < n;i++){
		cin >> a[i];
	}
	for(ll i = 0;i < n;i++){
		for(ll mask = 1;mask < 15;mask++){
			string x = "";
			ll cnt = 0;
			for(ll j = 0;j < 4;j++){
				if(mask & (1 << j)){
					x += a[i][j];cnt++;
				}
			}
			ans[3-cnt] += mp[mask][x];
			mp[mask][x]++;
		}
	}
	if(d == 1){
		cout << ans[0];
	}
	else if(d == 2){
		cout << ans[1] - ans[0] * 3;
	}
	else if(d == 3){
		cout << ans[2] - (ans[1] * 2 - ans[0] * 3);
	}
	else {
		cout << n * (n - 1)/2 - (ans[0]- ans[1]+ans[2]);
	}
	
	
}
int main()	
{
	ios_base::sync_with_stdio(false);	
	cin.tie(0);cout.tie(0);
	
	//freopen("A.in","r",stdin);
	//freopen("A.out","w",stdout);
	dumb_ass();
	
}   
#Verdict Execution timeMemoryGrader output
Fetching results...