Submission #531260

# Submission time Handle Problem Language Result Execution time Memory
531260 2022-02-28T09:34:30 Z hohohaha PIN (CEOI10_pin) C++14
100 / 100
157 ms 6024 KB
#include<bits/stdc++.h>
using namespace std;
#define fori(i, a, b) for(int i = (int) (a); i <= (int) (b); i++) 
#define ford(i, a, b) for(int i = (int) (a); i >= (int) (b); i--) 
#define ii pair<int, int> 
#define fi first
#define se second
#define vi vector<int> 
#define eb emplace_back
#define sp ' '
#define int long long

const int maxn = 5e4 + 4; 

int n, d; 
int co[16]; 
string s[maxn]; 

signed main() { 
	//freopen("PIN.inp", "r", stdin); 
	//freopen("PIN.out", "w", stdout); 
	ios_base::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0); 
	cin >> n >> d; 
	fori(i, 1, n) cin >> s[i]; 
	fori(mask, 0, 15) { 
		map<string, int> cnt; 
		fori(i, 1, n) { 
			string temp = s[i]; 
			fori(bit, 0, 3) { 
				if(mask >> bit & 1) { 
					temp[bit] = '-'; 
				}
			}
			cnt[temp]++;
		}
		for(auto t: cnt) {
			co[mask] += t.se * (t.se - 1) / 2; 
		}
	}
	
	int ans = 0; 
	fori(mask, 0, 15) { 
		fori(mask2, 0, mask - 1) { 
			if((mask2 & mask) == mask2) { 
				co[mask] -= co[mask2]; 
			}
		}
		if(__builtin_popcountll(mask) == d) ans += co[mask];
	}
	cout << ans; 
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1988 KB Output is correct
2 Correct 5 ms 2008 KB Output is correct
3 Correct 3 ms 1972 KB Output is correct
4 Correct 43 ms 3532 KB Output is correct
5 Correct 54 ms 3920 KB Output is correct
6 Correct 58 ms 3908 KB Output is correct
7 Correct 55 ms 3508 KB Output is correct
8 Correct 61 ms 4144 KB Output is correct
9 Correct 96 ms 5548 KB Output is correct
10 Correct 108 ms 5976 KB Output is correct
11 Correct 62 ms 4060 KB Output is correct
12 Correct 102 ms 5756 KB Output is correct
13 Correct 65 ms 4300 KB Output is correct
14 Correct 60 ms 4108 KB Output is correct
15 Correct 102 ms 5680 KB Output is correct
16 Correct 100 ms 4724 KB Output is correct
17 Correct 153 ms 5952 KB Output is correct
18 Correct 118 ms 5016 KB Output is correct
19 Correct 133 ms 5552 KB Output is correct
20 Correct 157 ms 6024 KB Output is correct