Submission #991627

#TimeUsernameProblemLanguageResultExecution timeMemory
991627pragmatistBad Codes (CCO19_day2problem3)C++17
0 / 100
114 ms46184 KiB
#include<bits/stdc++.h> using namespace std; int n, m; string a[55]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for(int i = 1; i <= n; ++i) { cin >> a[i]; } int mn = 1e9; map<string, int> cnt; for(int mask = 0; mask < (1 << n); ++mask) { vector<string> b, c; for(int i = 0; i < n; ++i) { if(mask >> i & 1) { b.push_back(a[i+1]); } } sort(b.begin(), b.end()); do { string cur; for(auto x : b) { cur += x; } c.push_back(cur); } while(next_permutation(b.begin(), b.end())); for(auto x : c) { if(cnt.count(x)) { mn = min(mn, (int)x.size()); } } for(auto x : c) { cnt[x]++; } } if(mn == 1e9) { cout << "-1"; return 0; } cout << mn; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...