Submission #638270

#TimeUsernameProblemLanguageResultExecution timeMemory
638270ieeNivelle (COCI20_nivelle)C++17
0 / 110
14 ms492 KiB
// iee
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <map>

#define rep(i, a, b) for (auto i = (a); i <= (b); ++i)
#define per(i, a, b) for (auto i = (a); i >= (b); --i)
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using namespace std;
void work(int);

template <class T> void read(T &x) {
  x = 0; int f = 1, ch = getchar();
  while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
  while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar();
  x *= f;
}

int main() {
  int TT = 1; // cin >> TT;
  rep(CAS, 1, TT)
    work(CAS);
  return 0;
}
const int N = 1e5 + 5;
int cnt[26];
int n;
int ansp = 1e9, ansq = 1;
int ansl, ansr;
char s[N];
void work(int CASE) {
  scanf("%d%s", &n, s + 1);
  rep(i, 1, n) {
    memset(cnt, 0, sizeof cnt);
    int num = 0;
    rep(j, i, min(n, i + 26)) {
      num += !cnt[s[j] - 'a']++;
      const int p = num, q = j - i + 1;
      if (1ll * ansp * q > 1ll * p * ansq) {
        ansp = p, ansq = q, ansl = i, ansr = j;
      }
    }
  }
  cout << ansl << ' ' << ansr;
}

Compilation message (stderr)

nivelle.cpp: In function 'void work(int)':
nivelle.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   scanf("%d%s", &n, s + 1);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
#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...