제출 #844872

#제출 시각아이디문제언어결과실행 시간메모리
844872vjudge1Nivelle (COCI20_nivelle)C++17
110 / 110
203 ms856 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define int int64_t #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ tree_order_statistics_node_update> #define F first #define S second #define I insert #define PB push_back #define POB pop_back #define sqr(a) ((a) * (a)) #define P pop #define max3(a, b, c) (max(a, max(b, c))) #define max4(a, b, c, d) (max(max(a, b), max(c, d))) #define min3(a, b, c) (min(a, min(b, c))) #define min4(a, b, c, d) (min(min(a, b), min(c, d))) #define MOD 1000000007 #define mod 998244353 int binpow(int a, int p, int m = MOD) { int ans = 1; while (p) { if (p & 1) ans = ((ans % m) * (a % m)) % m; a = sqr(a) % m; p >>= 1; } return ans; } void solve() { int n; string s; cin >> n >> s; set<char> sc; for (int i = 0; i < n; i++) sc.I(s[i]); double mini = 1; pair<int, int> posi = {0, 0}; for (int i = 1; i <= sc.size(); i++) { int r = 0, l = 0; map<char, int> m; m[s[r]]++; while (true) { if (l == n - 1) break; l++; m[s[l]]++; while (m.size() > i) { m[s[r]]--; if (m[s[r]] == 0) m.erase(s[r]); r++; } double curr = double(m.size()) / (l - r + 1); if (mini > curr) { mini = curr; posi.F = r; posi.S = l; } } } cout << posi.F + 1 << ' ' << posi.S + 1; } int32_t main() { int t = 1; // cin >> t; while (t--) { solve(); } }

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

nivelle.cpp: In function 'void solve()':
nivelle.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::set<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i = 1; i <= sc.size(); i++) {
      |                     ~~^~~~~~~~~~~~
nivelle.cpp:49:29: warning: comparison of integer expressions of different signedness: 'std::map<char, long int>::size_type' {aka 'long unsigned int'} and 'int64_t' {aka 'long int'} [-Wsign-compare]
   49 |             while (m.size() > i) {
      |                    ~~~~~~~~~^~~
#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...