제출 #844432

#제출 시각아이디문제언어결과실행 시간메모리
844432vjudge1Nivelle (COCI20_nivelle)C++17
0 / 110
18 ms856 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 20;
const ll MAXN = 1e6 + 5;

int cnt[26];
int main() {
	fast
	int N;
	string s;
	cin >> N >> s;
	s = "#" + s;

	double rate = 10.0;
	int ansL = -1, ansR = -1;
	for (int i = 1; i <= 26; i++) {
		memset(cnt, 0, sizeof(cnt));
		set<int> now;
		int L = 1;

		for (int R = 1; R <= N; R++) {
			now.insert(s[R] - 'a');
			cnt[s[R]]++;
			while (now.size() > i) {
				cnt[s[L]]--;
				if (cnt[s[L]] == 0)
					now.erase(s[L] - 'a');
				L++;
			}

			int all = R - L + 1;
			int q = i;
			double new_rate = ((double)q) / ((double)all);
			if (new_rate < rate) {
				rate = new_rate;
				ansL = L;
				ansR = R;
			}
		}
	}
	cout << ansL << " " << ansR << "\n";
}

컴파일 시 표준 에러 (stderr) 메시지

nivelle.cpp: In function 'int main()':
nivelle.cpp:29:12: warning: array subscript has type 'char' [-Wchar-subscripts]
   29 |    cnt[s[R]]++;
      |            ^
nivelle.cpp:30:22: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |    while (now.size() > i) {
      |           ~~~~~~~~~~~^~~
nivelle.cpp:31:13: warning: array subscript has type 'char' [-Wchar-subscripts]
   31 |     cnt[s[L]]--;
      |             ^
nivelle.cpp:32:17: warning: array subscript has type 'char' [-Wchar-subscripts]
   32 |     if (cnt[s[L]] == 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...