# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
868766 | Pring | Nivelle (COCI20_nivelle) | C++14 | 56 ms | 1620 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>
using namespace std;
#define int long long
#define fs first
#define sc second
#define mp make_pair
typedef pair<int, int> pii;
typedef pair<pii, int> p3i;
const int MXN = 100005, MXC = 26;
int n;
string s;
deque<int> dq[MXC];
pii ans;
double x = 3000000000000000000.0;
void miku() {
cin >> n >> s;
for (int i = 0; i < n; i++) {
dq[s[i] - 'a'].push_back(i);
}
for (int i = 0; i < MXC; i++) dq[i].push_back(-1);
for (int i = 0; i < n; i++) {
vector<int> v;
for (int j = 0; j < MXC; j++) if (dq[j].front() != -1) v.push_back(dq[j].front());
v.push_back(n);
sort(v.begin(), v.end());
// cout << i << endl;
// for (auto &j : v) cout << j << ' ';
// cout << endl;
for (int j = 1; j < v.size(); j++) {
double xx = (double) j / (v[j] - i);
if (xx < x) {
x = xx;
ans = mp(i, v[j]);
}
}
dq[s[i] - 'a'].pop_front();
}
cout << ans.fs + 1 << ' ' << ans.sc << endl;
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
miku();
return 0;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |