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

제출 #1106374

#제출 시각아이디문제언어결과실행 시간메모리
110637412345678Nivelle (COCI20_nivelle)C++17
110 / 110
27 ms848 KiB
#include <bits/stdc++.h> using namespace std; int n, a=1, b=1, l=1, r=1, lst[27]; string s; set<int> ms; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>s; for (int i=0; i<26; i++) lst[i]=1; ms.insert(1); for (int i=0; i<n; i++) { if (lst[s[i]-'a']!=1) ms.erase(lst[s[i]-'a']); lst[s[i]-'a']=-i; ms.insert(-i); int cnt=0; for (auto x:ms) { int tmp=-x; cnt++; if (cnt>1) { if (a*(i-tmp)>b*(cnt-1)) a=cnt-1, b=i-tmp, l=tmp+2, r=i+1; //cout<<"debug "<<i<<' '<<tmp<<' '<<a<<' '<<b<<' '<<cnt-1<<' '<<i-tmp<<'\n'; } } } cout<<l<<' '<<r; }
#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...