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

제출 #236041

#제출 시각아이디문제언어결과실행 시간메모리
236041caoashNivelle (COCI20_nivelle)C++14
110 / 110
111 ms10996 KiB
#include<bits/stdc++.h> using namespace std; int n, lst[27][100002]; string s; int L, R, col; void chk(int st, int dr, int cnt) { if(L == 0) { L = st; R = dr; col = cnt; } else { long long a = cnt; long long b = dr - st + 1; long long c = col; long long d = R - L + 1; if(a * d < b * c) { L = st; R = dr; col = cnt; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; cin >> s; s = ' ' + s; for(int i = 1; i <= n; ++i) { for(int j = 0; j <= 25; ++j) lst[j][i] = lst[j][i-1]; lst[s[i] - 'a'][i] = i; vector<int> v; for(int j = 0; j <= 25; ++j) if(lst[j][i] != 0) v.push_back(lst[j][i]); v.push_back(0); sort(v.begin(), v.end()); for(int x = v.size() - 1; x > 0; --x) chk(v[x - 1] + 1, i, v.size() - x); } cout << L << " " << R << '\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...