제출 #658400

#제출 시각아이디문제언어결과실행 시간메모리
658400sam571128Set (COCI21_set)C++17
40 / 110
552 ms468 KiB
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(0); cin.tie(0);

using namespace std;

const int N = 2205;
vector<int> cards[N];
int cnt[N];

int encode(vector<int> v){
	int num = 0, now = 1;
	for(auto x : v){
		num += x*now;
		now *= 3;
	}
	return num;
}

signed main(){
	fastio
	int n,k;
	cin >> n >> k;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < k; j++){
			char c;
			cin >> c;
			cards[i].push_back(c-'0'-1);
		}
		cnt[encode(cards[i])]++;
	}

	int ans = 0;

	for(int i = 0; i < n; i++){
		cnt[encode(cards[i])]--;
		for(int j = i+1; j < n; j++){
			cnt[encode(cards[j])]--;
			vector<int> need;
			for(int x = 0; x < k; x++){
				if(cards[i][x]==cards[j][x]){
					need.push_back(cards[i][x]);
				}else{
					need.push_back(3-cards[i][x]-cards[j][x]);
				}
			}
			ans += cnt[encode(need)];
		}
		for(int j = i+1; j < n; j++){
			cnt[encode(cards[j])]++;
		}
	}

	cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...