| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 571792 | Blagojce | PIN (CEOI10_pin) | C++11 | 344 ms | 18388 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 = 4-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 | 
|---|---|---|---|---|
| Fetching results... | ||||
