(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #206740

#제출 시각아이디문제언어결과실행 시간메모리
206740wiwihoNivelle (COCI20_nivelle)C++14
110 / 110
16 ms636 KiB
//#define NDEBUG #include <bits/stdc++.h> #include <bits/extc++.h> #define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define iter(a) a.begin(), a.end() #define riter(a) a.rbegin(), a.rend() #define lsort(a) sort(iter(a)) #define gsort(a) sort(riter(a)) #define mp(a, b) make_pair(a, b) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define pf(a) push_front(a) #define pob pop_back() #define pof pop_front() #define F first #define S second #define printv(a, b) {bool pvaspace=false; \ for(auto pva : a){ \ if(pvaspace) b << " "; pvaspace=true;\ b << pva;\ }\ b << "\n";} #define pii pair<int, int> #define pll pair<ll, ll> #define tiii tuple<int, int, int> #define mt make_tuple #define gt(t, i) get<i>(t) #define iceil(a, b) ((a) / (b) + !!((a) % (b))) //#define TEST typedef long long ll; typedef unsigned long long ull; using namespace std; using namespace __gnu_pbds; const ll MOD = 1000000007; const ll MAX = 2147483647; template<typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> p){ return o << '(' << p.F << ',' << p.S << ')'; } int main(){ StarBurstStream int n; cin >> n; string s; cin >> s; vector<int> lst(26, -1); vector<int> cnt(27, -1); int l = -1, r = -1; double v = 2; for(int i = 0; i < n; i++){ int c = s[i] - 'a'; if(lst[c] == -1){ for(int j = 26; j > 1; j--) cnt[j] = cnt[j - 1]; cnt[1] = i; } else{ int j = 0; for(; j < 26 && lst[c] < cnt[j + 1]; j++); for(; j > 1; j--) cnt[j] = cnt[j - 1]; if(j != 0) cnt[1] = i; } lst[c] = i; // printv(cnt, cerr); for(int j = 1; j <= 26; j++) if(cnt[j] != -1){ if((double)j / (i - cnt[j] + 1) < v){ v = (double)j / (i - cnt[j] + 1); l = cnt[j]; r = i; } } } // cerr << v << "\n"; cout << l + 1 << " " << r + 1 << "\n"; return 0; }
#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...