Submission #844496

#TimeUsernameProblemLanguageResultExecution timeMemory
844496vjudge1Nivelle (COCI20_nivelle)C++17
0 / 110
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #include "/Users/kutay/CP/templates/debug.h" #else #define debug(...) void(38) #endif #define int long long int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; vector<int> m(26); int cnt = 0; for (char c : s) m[c - 'a']++; for (int x : m) cnt += (bool) x; int l = 0, r = n - 1; while (l < r) { double d = (double) cnt / (r - l + 1); if (m[s[l] - 'a'] == 1) { m[s[l] - 'a']--; cnt--; l++; continue; } if (m[s[r] - 'a'] == 1) { m[s[r] - 'a']--; cnt--; r--; continue; } break; } cout << l + 1 << " " << r + 1 << '\n'; }

Compilation message (stderr)

nivelle.cpp: In function 'int32_t main()':
nivelle.cpp:23:12: warning: unused variable 'd' [-Wunused-variable]
   23 |     double d = (double) cnt / (r - l + 1);
      |            ^
#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...