Submission #658397

#TimeUsernameProblemLanguageResultExecution timeMemory
658397sam571128Set (COCI21_set)C++17
10 / 110
1086 ms764 KiB
#include <bits/stdc++.h>

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

using namespace std;

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


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[cards[i]]++;
	}

	int ans = 0;

	for(int i = 0; i < n; i++){
		cnt[cards[i]]--;
		for(int j = i+1; j < n; j++){
			cnt[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[need];
		}
		for(int j = i+1; j < n; j++){
			cnt[cards[j]]++;
		}
	}

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