// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 1e6 + 5;
inline void solve(){
double n;
string s;
cin >> n >> s;
double ok[26], cnt = 0, l, r;
fill(ok, ok+26, 0);
double mn = n +5;
rep(i, 0, n){
rep(j, i, n){
if(!ok[s[j] - 'a']){
ok[s[j] - 'a'] = 1;
cnt++;
}
double ans = cnt / (j-i+1);
if(mn > ans){
mn = ans;
l = i, r = j;
}
}
cnt = 0;
fill(ok, ok+26, 0);
}
cout << l+1 << " " << r+1 << endl;
}
int main(){
fast_io
int t;
t = 1;
while(t--) solve();
}
Compilation message
nivelle.cpp: In function 'void solve()':
nivelle.cpp:41:29: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
41 | cout << l+1 << " " << r+1 << endl;
| ^
nivelle.cpp:41:15: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
41 | cout << l+1 << " " << r+1 << endl;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
7 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
344 KB |
Output is correct |
5 |
Correct |
6 ms |
348 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1047 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1052 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |