이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
#define endl '\n'
#define fi first
#define se second
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define CDIV(a,b) (((a)+(b)-(1))/(b))
const ll inf = 1e17 + 5;
const ll mod = 1e9 + 7;
const ll N = 1e3 + 30;
int mod_(int a, int b)
{
if(a >= 0)return a % b;
a += (-a/b + 1) * b;
return a % b;
}
ld eps = 1e-9;
void solve()
{
int n;
string a;
cin >> n >> a;
set<char>s;
long double ans = 1LL;
int ansl = 0, ansr = 0;
for(int l = 0; l < n; ++l)
{
for(int r = l + 1; r < n; ++r)
{
s.clear();
for(int i = l; i <= r; ++i)s.insert(a[i]);
//cout << l << ' ' << r << ' ' << s.size() << ' ' << (ld)(s.size())/(r - l + 1) << endl;
if((ld)(s.size())/(r - l + 1) < ans - eps)
{
ans = (ld)(s.size())/(r - l + 1);
ansl = l;
ansr = r;
}
}
}
cout << ansl + 1 << ' ' << ansr + 1 << endl;
}
int main()
{
fio;
//int t; cin >> t; while(t--)
{
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |