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

제출 #1017322

#제출 시각아이디문제언어결과실행 시간메모리
1017322vjudge1Nivelle (COCI20_nivelle)C++17
110 / 110
401 ms8460 KiB
#include<bits/stdc++.h> using namespace std; const int N = 100'010, K = 19; int sp[N][K]; int getor(int l, int r) { // cerr << l << ' ' << r << endl; int b = 31 - __builtin_clz(r - l); // cerr << b << endl; return (sp[l][b] | sp[r - (1 << b)][b]); } bool smaller(vector<int> a, vector<int> b) { return a[0] * b[1] < b[0] * a[1]; } int main() { int n; string s; cin >> n >> s; int mask[n]; for(int i = 0; i < n; i ++) mask[i] = 1 << (s[i] - 'a'); for(int i = n - 1; i >= 0; i --) { sp[i][0] = mask[i]; for(int l = 1; i + (1 << l) <= n; l++) sp[i][l] = (sp[i][l - 1] | sp[i + (1 << (l - 1))][l - 1]); } vector<int> ans; // set sz s e ans = {1, 1, 1, 1}; for(int i = 0; i < n; i ++) { // cerr << i << endl; int cur = 0; while(cur < getor(i, n)) { int l = i, r = n; while(r - l > 1) { int m = (l + r) / 2; if(getor(i, m) <= cur) l = m; else r = m; } if(smaller({__builtin_popcount(cur), l - i, i + 1, l}, ans)) ans = {__builtin_popcount(cur), l - i, i + 1, l}; cur = getor(i, r); } cur = getor(i, n); // cerr << "out : " << __builtin_popcount(cur) << ' ' << i + 1 << ' ' << n << endl; if(smaller({__builtin_popcount(cur), n - i, i + 1, n}, ans)) ans = {__builtin_popcount(cur), n - i, i + 1, n}; } cout << ans[2] << ' ' << ans[3] << endl; 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...