이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |