(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 #1101126

#TimeUsernameProblemLanguageResultExecution timeMemory
1101126InvMODNivelle (COCI20_nivelle)C++14
110 / 110
159 ms46356 KiB
#include <bits/stdc++.h> using namespace std; #define gcd __gcd #define fi first #define se second #define lcm(a, b) a*b/gcd(a,b) #define sz(v) v.size() #define pb push_back #define el "\n" #define pi pair<ll , ll> #define all(v) (v).begin(), (v).end() #define rev(v) reverse(all(v)) #define compact(v) v.erase(unique(all(v)), end(v)) ///#define int long long using ll = long long; using ld = long double; using ull = unsigned long long; template<typename T> bool ckmx(T &a, T b){if(a < b) return a = b, true; return false;} template<typename T> bool ckmn(T &a, T b){if(a > b) return a = b, true; return false;} const int lg = 18; const int N = 1e5+1; const ll MOD = 1e9+7; const ll INF = 1e18; bool rmq[26][lg][N]; void preprocess(int n){ for(int c = 0; c < 26; c++){ for(int i = 1; (1<<i) <= n; i++){ for(int j = 1; j + (1<<i)-1 <= n; j++){ rmq[c][i][j] = (rmq[c][i-1][j] | rmq[c][i-1][j + (1<<(i-1))]); } } } return; } int distinct(int l, int r){ int res = 0; int k = 31 - __builtin_clz(r-l+1); for(int i = 0; i < 26; i++){ res += (rmq[i][k][l] | rmq[i][k][r-(1<<k)+1]); } return res; } bool larger(tuple<int,int,int> a, tuple<int,int,int> b){ int range1 = get<2>(a) - get<1>(a) + 1; int range2 = get<2>(b) - get<1>(b) + 1; int disc1 = get<0>(a), disc2 = get<0>(b); return (disc1 * range2) > (disc2 * range1); } void solve() { int n; cin >> n; string s; cin >> s; s = " " + s; for(int i = 1; i <= n; i++){ rmq[s[i] - 'a'][0][i] = 1; } preprocess(n); tuple<int,int,int> mx = {1, 1, 1}; for(int nd = 1; nd <= 26; nd++){ int l = 1; for(int i = 1; i <= n; i++){ while(distinct(l, i) > nd) l++; if(larger(mx, make_tuple(nd, l, i))) mx = make_tuple(nd, l, i); } } cout << get<1>(mx) <<" " << get<2>(mx) <<"\n"; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "InvMOD" if(fopen(name".INP", "r")){ freopen(name".INP","r",stdin); freopen(name".OUT","w",stdout); } int t = 1; //cin >> t; while(t--) solve(); return 0; }

Compilation message (stderr)

nivelle.cpp: In function 'int main()':
nivelle.cpp:89:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |         freopen(name".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
nivelle.cpp:90:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   90 |         freopen(name".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...