# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833978 | helloworld1705 | Bad Codes (CCO19_day2problem3) | C++14 | 5 ms | 1876 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
_ _
| | (_)
| |__ __ _ ___ _ ___
| '_ \ / _` / __| |/ __|
| |_) | (_| \__ \ | (__
|_.__/ \__,_|___/_|\___|
*/
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e6 + 5;
#define pii pair <int , int>
#define fi first
#define se second
#define bit(a,b) ((a >> b) & 1ll)
const int M = 1e3 + 3;
const int inf = 1e18;
const int mod = 1e9 + 7;
int TEST = 0;
void STEST();
/* -----------------[ MAIN CODE GOES HERE ]----------------- */
void init() {
}
string s[10001];
set <string> st;
void solve() {
int n , m;
cin >> n >> m;
for(int i = 0; i < n; i++) {
cin >> s[i];
}
int res = inf;
for(int sz = 1; sz < 7; sz++) {
for(int i = 0; i < (1 << (sz * 2)); i++) {
string ans = "";
int x = i;
for(int j = 0; j < sz; j++) {
ans += s[x & 3];
x = (x >> 2);
}
if(st.find(ans) == st.end()) {
st.insert(ans);
continue;
}
int SIZE = ans.size();
res = min(res , SIZE);
}
}
cout << (res == inf ? -1 : res) << '\n';
return;
}
main() {
if (fopen("code.inp", "r")) {
freopen("code.inp", "r", stdin);
freopen("code.out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
STEST();
if(TEST) {
int t;
cin >> t;
while(t-->0) {
// your code down here //
solve();
}
}
else {
solve();
}
return 0x0;
}
void STEST() {
}
// code by nothing //
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |