답안 #385213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
385213 2021-04-03T16:58:21 Z ritul_kr_singh PIN (CEOI10_pin) C++17
0 / 100
7 ms 2156 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'

int mask;

bool comp(string x, string y){
	for(int i=0; i<4; ++i){
		if(((1<<i)&mask) and x[i]!=y[i]) return x[i]<y[i];
	}
	return false;
}

bool equal(string x, string y){
	return comp(x, y)==comp(y, x);
}

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, d, ans = 0; cin >> n >> d;
	string a[n]; for(auto &i : a) cin >> i;
	d = n-d;

	for(mask=0; mask<16; ++mask){
		int cnt = 0;
		for(int i=0; i<4; ++i) if((1<<i)&mask) ++cnt;
		if(cnt<d) continue;

		sort(a, a+n, comp);
		for(int i=0; i<n; ++i){
			int j = i;
			while(j+1<n and equal(a[i], a[j+1])) ++j;
			ans += ((cnt-d)%2 ? -1 : 1) * ((j-i+1)*(j-i))/2;
			i = j;
		}
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Incorrect 2 ms 364 KB Output isn't correct
4 Incorrect 3 ms 1004 KB Output isn't correct
5 Incorrect 4 ms 1260 KB Output isn't correct
6 Incorrect 4 ms 1280 KB Output isn't correct
7 Incorrect 3 ms 1004 KB Output isn't correct
8 Incorrect 4 ms 1260 KB Output isn't correct
9 Incorrect 5 ms 1900 KB Output isn't correct
10 Incorrect 6 ms 2156 KB Output isn't correct
11 Incorrect 4 ms 1260 KB Output isn't correct
12 Incorrect 6 ms 2028 KB Output isn't correct
13 Incorrect 5 ms 1388 KB Output isn't correct
14 Incorrect 4 ms 1260 KB Output isn't correct
15 Incorrect 6 ms 2028 KB Output isn't correct
16 Incorrect 4 ms 1516 KB Output isn't correct
17 Incorrect 6 ms 2156 KB Output isn't correct
18 Incorrect 5 ms 1644 KB Output isn't correct
19 Incorrect 7 ms 2028 KB Output isn't correct
20 Incorrect 6 ms 2156 KB Output isn't correct