# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844496 | vjudge1 | Nivelle (COCI20_nivelle) | C++17 | 1 ms | 604 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;
#ifdef DEBUG
#include "/Users/kutay/CP/templates/debug.h"
#else
#define debug(...) void(38)
#endif
#define int long long
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
string s; cin >> s;
vector<int> m(26);
int cnt = 0;
for (char c : s) m[c - 'a']++;
for (int x : m) cnt += (bool) x;
int l = 0, r = n - 1;
while (l < r) {
double d = (double) cnt / (r - l + 1);
if (m[s[l] - 'a'] == 1) {
m[s[l] - 'a']--;
cnt--;
l++;
continue;
}
if (m[s[r] - 'a'] == 1) {
m[s[r] - 'a']--;
cnt--;
r--;
continue;
}
break;
}
cout << l + 1 << " " << r + 1 << '\n';
}
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... |