(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.

Submission #234829

#TimeUsernameProblemLanguageResultExecution timeMemory
234829dooweyNivelle (COCI20_nivelle)C++14
110 / 110
40 ms632 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int AL = 26; int las[AL]; struct F{ int A; int B; int li; int ri; bool operator< ( const F &C) const { return A * C.B < C.A * B; } }; int main(){ fastIO; int n; cin >> n; for(int i = 0 ; i < AL; i ++ ){ las[i]=-1; } F cur = {1, 1, 1, 1}; char in; int d; set<int> pos; pos.insert(0); int cnt; for(int i = 1; i <= n; i ++){ cin >> in; d = in - 'a'; if(las[d] != -1){ pos.erase(las[d]); } pos.insert(i); auto it = pos.end(); it--; cnt = 0; F tri; while(it != pos.begin()){ auto pv = it; pv -- ; cnt ++ ; tri = {cnt, i - (*pv), (*pv) + 1, i}; cur = min(cur, tri); it = pv; } las[d]=i; } cout << cur.li << " " << cur.ri << "\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...