Submission #212068

#TimeUsernameProblemLanguageResultExecution timeMemory
212068NONAMENivelle (COCI20_nivelle)C++17
24 / 110
1087 ms640 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") #define F first #define S second #define sz(x) int(x.size()) using namespace std; typedef long double ld; int main() { //freopen("army.in","r",stdin); freopen("army.out","w",stdout); ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; bool f = 1; for (int i = 0; i < n; i++) if (s[i] != 'a' && s[i] != 'b') f = 0; ld ans = 1e18, l, r; if (f) { char lst = s[0]; int k = 1; for (int i = 1; i < n; i++) { if (lst == s[i]) {k++; continue;} ld x = 1, y = k; if (x / y < ans) {ans = x / y; r = i - 1; l = i - k;} lst = s[i]; k = 1; } ld x = 1, y = k; if (x / y < ans) {ans = x / y; r = n - 1; l = n - k;} x = 2; y = n; if (x / y < ans) {ans = x / y; r = n - 1; l = 0;} cout << l << " " << r << endl; exit(0); } for (int i = 0; i < n; i++) { set <char> se; se.clear(); for (int j = i; j < n; j++) { se.insert(s[j]); ld x = sz(se), y = j - i + 1; if (ans > x / y) {ans = x / y; l = i; r = j;} } } cout << l + 1 << " " << r + 1 << endl; }

Compilation message (stderr)

nivelle.cpp: In function 'int main()':
nivelle.cpp:81:33: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
     cout << l + 1 << " " << r + 1 << endl;
                                 ^
nivelle.cpp:81:17: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
     cout << l + 1 << " " << r + 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...