Submission #442953

#TimeUsernameProblemLanguageResultExecution timeMemory
442953Dipto_DebdipNivelle (COCI20_nivelle)C++14
24 / 110
634 ms524292 KiB
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
  return a.second - a.first > b.second - b.first;
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  string s;
  cin >> n;
  cin >> s;
  set<char> st;
  vector<pair<pair<ll, ll>, pair<ll, ll>>> v;
  //ll l2 = 10000, d2 = 10000;
  for (ll i = 0; i < n; i++) {
    map<char, ll> mp;
    ll l1 = 0, l2 = 0;
    st.insert(s[i]);
    for (ll j = i; j < n; j++) {
      if (!mp[s[j]]) {
        l1++;
        mp[s[j]]++;
      }
      l2++;
      v.push_back({{i, j}, {l1, l2}});
    }
  }
  ll l, r;
  ll c1 = 10000, c2 = 10000;
  for (auto i : v) {
    ll h1 = i.second.first;
    ll h2 = i.first.second - i.first.first + 1;
    if (c1 * h2 > h1 * c2) {
      l = i.first.first + 1;
      r = i.first.second + 1;
      c1 = h1;
      c2 = h2;
    }
  }
  if (st.size() == n) cout << "1 1" << endl;
  else cout << l << " " << r << endl;
  return 0;
}

Compilation message (stderr)

nivelle.cpp: In function 'int main(int, const char**)':
nivelle.cpp:42:17: warning: comparison of integer expressions of different signedness: 'std::set<char>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   42 |   if (st.size() == n) cout << "1 1" << endl;
      |       ~~~~~~~~~~^~~~
#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...