Submission #212131

#TimeUsernameProblemLanguageResultExecution timeMemory
212131NONAMENivelle (COCI20_nivelle)C++17
0 / 110
37 ms640 KiB
#include <bits/stdc++.h> #include <time.h> #include <random> #ifndef _LOCAL #pragma GCC optimize("-O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #endif #define sz(x) int(x.size()) #define in(x) freopen(x,"r",stdin) #define out(x) freopen(x,"w",stdout) #define N 100500 #define oo ll(1e16) #define pii pair <int, int> #define pll pair <ll, ll> #define ft first #define sd second #define pb push_back #define el '\n' #define elf endl #define base ll(1e9 + 7) #define re return #define nins 4294967295 using namespace std; typedef long long ll; typedef long double ld; mt19937 rnd(0); ll add(ll x, ll y, ll mod) { return (mod == 0) ? (x + y) : (x + y) % mod; } ll mul(ll x, ll y, ll mod) { return (mod == 0) ? (x * y) : (x * y) % ll(mod); } int n, res, l, r, f[26]; string s; vector <pii> lst(26); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef _LOCAL in("input.txt"); clock_t start_time = clock(); #endif cin >> n; cin >> s; res = 1; l = r = 0; for (int i = 0; i < 26; i++) f[i] = -1, lst[i].ft = -1, lst[i].sd = i; for (int i = 0; i < n; i++) { int c = s[i] - 'a'; if (f[c] != -1) continue; f[c] = i; } for (int i = 0; i < n; i++) { int c = s[i] - 'a'; for (int j = 0; j < 26; j++) if (lst[j].sd == c) lst[j].ft = i; sort(lst.begin(), lst.end()); for (int j = 0; j < 26; j++) { int x = lst[j].ft; if (x == -1) continue; if ((26 - j) * (r - l + 1) < res * (i - f[lst[j].sd] + 1)) { res = 26 - j; l = f[lst[j].sd]; r = i; } } } cout << l + 1 << ' ' << r + 1; #ifdef _LOCAL cerr.precision(4); cerr << fixed; cerr << el; cerr << "Time :: " << ld(clock() - start_time) / CLOCKS_PER_SEC << el; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...