Submission #1274250

#TimeUsernameProblemLanguageResultExecution timeMemory
1274250SmuggingSpunNivelle (COCI20_nivelle)C++20
110 / 110
47 ms15344 KiB
#include<bits/stdc++.h>
#define taskname "E"
using namespace std;
const int lim = 1e5 + 5;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	int n;
	string s;
	cin >> n >> s;
	vector<vector<int>>p(n + 1, vector<int>(27, n));
	for(int i = n - 1; i > -1; i--){
		p[i] = p[i + 1];
		p[i][s[i] -= 'a'] = i;
	}
	int L = -1, R, C;
	for(int i = 0; i < n; i++){
		sort(p[i].begin(), p[i].end());
		for(int j = 0; p[i][j] != n; j++){
			if(L == -1 || 1LL * (j + 1) * (R - L + 1) < 1LL * C * (p[i][j + 1] - i)){
				L = i;
				R = p[i][j + 1] - 1;
				C = j + 1;
			}
		}
	}
	cout << L + 1 << " " << R + 1;
}

Compilation message (stderr)

nivelle.cpp: In function 'int main()':
nivelle.cpp:8:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...