Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.005 s | 0 KBi |
#2 |
Incorrecto
|
0.006 s | 2 KBi |
#3 |
Correcto
|
0.006 s | 13 KBi |
#4 |
Incorrecto
|
0.008 s | 9 KBi |
#5 |
Incorrecto
|
0.006 s | 34 KBi |
#6 |
Correcto
|
0.006 s | 9 KBi |
#7 |
Correcto
|
0.005 s | 10 KBi |
#8 |
Incorrecto
|
0.003 s | 10 KBi |
#9 |
Correcto
|
0.007 s | 12 KBi |
#10 |
Correcto
|
0.004 s | 16 KBi |
#11 |
Correcto
|
0.008 s | 6 KBi |
#12 |
Incorrecto
|
0.012 s | 3 KBi |
#13 |
Incorrecto
|
0.032 s | 43 KBi |
#14 |
Incorrecto
|
0.021 s | 5 KBi |
#15 |
Incorrecto
|
0.014 s | 5 KBi |
#16 |
Incorrecto
|
0.008 s | 4 KBi |
#17 |
Incorrecto
|
0.01 s | 1 KBi |
#18 |
Incorrecto
|
0.009 s | 1 KBi |
#19 |
Incorrecto
|
0.023 s | 3 KBi |
#20 |
Incorrecto
|
0.016 s | 6 KBi |
#21 |
Incorrecto
|
0.012 s | 2 KBi |
#22 |
Incorrecto
|
0.017 s | 4 KBi |
#23 |
Incorrecto
|
0.008 s | 4 KBi |
#24 |
Incorrecto
|
0.015 s | 1 KBi |
#25 |
Incorrecto
|
0.018 s | 3 KBi |
#26 |
Incorrecto
|
0.013 s | 5 KBi |
#27 |
Incorrecto
|
0.011 s | 2 KBi |
#28 |
Incorrecto
|
0.008 s | 18 KBi |
#29 |
Incorrecto
|
0.012 s | 2 KBi |
#30 |
Incorrecto
|
0.006 s | 1 KBi |
#31 |
Incorrecto
|
0.005 s | 2 KBi |
#32 |
Incorrecto
|
0.005 s | 2 KBi |
// #include <bits/stdc++.h> using namespace std; #define INF 1000000000 #define MOD 1000000007 #define PI 3.14159265 #define EPS 1e-9 #define Pi acos(-1.0) typedef pair<int, int> ii; typedef long long ll; typedef vector<ll> vll; typedef pair<ll,ll> pll; #define forr(i,a,b) for(int i=(a); i<(b); i++) #define clean(arr,val) memset(arr,val,sizeof(arr)) #define forn(i,n) forr(i,0,n) #define PB push_back typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vpll; /*CODE START HERE*/ int visited[30]; int ans, k, aS, pivot, different; string s; int main(){ ios::sync_with_stdio(0); clean(visited,0); cin >> s; cin >> k; ans = INF; aS = 0; pivot = 0; different = 0; forn(i,(int)s.size()){ // cout << "NOW ON " << s[i] << " AS " << aS << " PIVOT " << pivot << " DIFFERENT " << different << "\n"; if(visited[s[i]-'a']){ cout << "YA HA APARECIDO\n"; for(int j = pivot; j < i; j++){ aS--; visited[s[j]-'a']--; if(visited[s[j]-'a'] == 0){ pivot = j+1; different--; break; } } } visited[s[i]-'a']++; if(visited[s[i]-'a'] == 1){ different++; } if(different > k){ cout << "IN\n"; for(int j = pivot; j <= i; j++){ aS--; visited[s[j]-'a']--; if(visited[s[j]-'a'] == 0){ different--; } if(different < k){ pivot = j; different++; visited[s[j]-'a']++; aS++; break; } } } aS++; // cout << "NOW ON " << s[i] << " AS " << aS << " PIVOT " << pivot << " DIFFERENT " << different << "\n"; if(different==k) ans = min(ans,aS); char temp = s[i]; while(true){ i++; if(i >= (int)s.size()){ break; } if(s[i] != temp){ i--; break; } visited[s[i]-'a']++; aS++; if(different==k) ans = min(ans,aS); } // cout << "NOW ON " << s[i] << " AS " << aS << " PIVOT " << pivot << " DIFFERENT " << different << "\n"; } if(ans == INF) ans = -1; cout << ans << "\n"; return 0; }