Hi, can anyone tell me why this is TLE for this problem: USACO
The complexity should be enough to run right?
Works fine on my compiler
#include <bits/stdc++.h>
using namespace std;
ifstream fin("cownomics.in");
ofstream fout("cownomics.out");
int n, m, ans = 0;
vector<string> inp1, inp2;
// int res = 0;
bool ok(int ind1, int ind2, int ind3){
vector<vector<vector<bool>>> has(26, vector<vector<bool>>(26, vector<bool> (26,0)));
for(int i = 0; i < n; ++i){
char n1 = inp2[i][ind1];
char n2 = inp2[i][ind2];
char n3 = inp2[i][ind3];
has[n1 - 'A'][n2 - 'A'][n3 - 'A'] = 1;
}
for(int i = 0; i < n; ++i){
char n1 = inp1[i][ind1];
char n2 = inp1[i][ind2];
char n3 = inp1[i][ind3];
if(has[n1 - 'A'][n2 - 'A'][n3 - 'A']){
return 0;
}
}
return 1;
}
int main() {
fin >> n >> m;
inp1.resize(n);
inp2.resize(n);
for(int i = 0; i < n; ++i){
fin >> inp1[i];
}
for(int i = 0; i < n; ++i){
fin >> inp2[i];
}
for(int i = 0; i < m; ++i){
for(int j = i+1; j < m; ++j){
for(int k = j+1; k < m; ++k){
if(ok(i, j, k)){
++ans;
}
}
}
}
fout << ans;
}