Submission #991627

# Submission time Handle Problem Language Result Execution time Memory
991627 2024-06-02T17:13:15 Z pragmatist Bad Codes (CCO19_day2problem3) C++17
0 / 100
114 ms 46184 KB
#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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 468 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 46184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 468 KB Output isn't correct
4 Halted 0 ms 0 KB -