Submission #1147053

#TimeUsernameProblemLanguageResultExecution timeMemory
1147053UnforgettableplSet (COCI21_set)C++20
40 / 110
1096 ms70984 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int modulo = 1e9+7; const int INF = 1e15; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,k; cin >> n >> k; vector<bool> present(pow(3ll,k)); auto convert = [&](vector<int> x){ int p = 1; int ans = 0; for(int&i:x){ ans+=p*i; p*=3ll; } return ans; }; vector seqs(n,vector<int>(k)); for(auto&i:seqs){ for(int&j:i){ char x; cin >> x; j = x-'1'; } present[convert(i)]=true; } vector<vector<int>> table = { {0,2,1}, {2,1,0}, {1,0,2}, }; int ans = 0; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ vector<int> shouldbe(k); for(int l=0;l<k;l++)shouldbe[l]=table[seqs[i][l]][seqs[j][l]]; if(present[convert(shouldbe)])ans++; } } cout << ans/3ll << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...