답안 #917410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917410 2024-01-28T05:45:10 Z PM1 PIN (CEOI10_pin) C++17
100 / 100
290 ms 16372 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxn=5e4+5;
int n,d;
string s[mxn];
map<vector<char>,int>mp[(1<<4)];
ll ans[4];
int main(){
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		for(int j=0;j<(1<<4)-1;j++){
			int cnt=0;
			vector<char>v;
			for(int k=0;k<4;k++){
				if(j&(1<<k)){
					cnt++;
					v.push_back(s[i][k]);
				}
			}
			ans[3-cnt]+=mp[j][v];
			mp[j][v]++;
			//cout<<j<<" "<<mp[j][v]<<endl;
		}//cout<<endl;
	}
	ans[1]-=(ans[0]*3);
	ans[2]-=(ans[1]*2+ans[0]*3);
	ans[3]-=ans[1]+ans[2]+ans[0];
	cout<<ans[d-1]<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2652 KB Output is correct
2 Correct 7 ms 2660 KB Output is correct
3 Correct 6 ms 2396 KB Output is correct
4 Correct 71 ms 3708 KB Output is correct
5 Correct 88 ms 3924 KB Output is correct
6 Correct 96 ms 3924 KB Output is correct
7 Correct 71 ms 3924 KB Output is correct
8 Correct 97 ms 3904 KB Output is correct
9 Correct 158 ms 3888 KB Output is correct
10 Correct 178 ms 4180 KB Output is correct
11 Correct 95 ms 3924 KB Output is correct
12 Correct 163 ms 3712 KB Output is correct
13 Correct 105 ms 3920 KB Output is correct
14 Correct 99 ms 3716 KB Output is correct
15 Correct 163 ms 3924 KB Output is correct
16 Correct 172 ms 13328 KB Output is correct
17 Correct 287 ms 16192 KB Output is correct
18 Correct 204 ms 14108 KB Output is correct
19 Correct 237 ms 15488 KB Output is correct
20 Correct 290 ms 16372 KB Output is correct