Submission #1103942

#TimeUsernameProblemLanguageResultExecution timeMemory
1103942thangdz2k7Difference (POI11_roz)C++17
100 / 100
115 ms3308 KiB
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define endl '\n' using namespace std; using ll = long long; using ii = pair <int, int>; using vi = vector <int>; const int N = 1e6 + 1; const int mod = 1e9 + 7; const int nc = 26; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} int n, cur[nc], Min[nc], ntm[nc]; string s; void solve(){ cin >> n; cin >> s; s = ' ' + s; int ans = 0; for (int u = 0; u < nc; ++ u){ for (int v = 0; v < nc; ++ v) { cur[v] = 0; Min[v] = 1e9; ntm[v] = 0; } for (int i = 1; i <= n; ++ i){ int v = s[i] - 'a'; if (u == v) { for (int k = 0; k < nc; ++ k) { cur[k] ++; if (k != u){ minl(ntm[k], cur[k]); maxl(ans, cur[k] - Min[k]); } } } else { cur[v] --; minl(Min[v], ntm[v]); ntm[v] = cur[v]; maxl(ans, cur[v] - Min[v]); } } } cout << ans; } int main(){ if (fopen("chenhlech.inp", "r")){ freopen("chenhlech.inp", "r", stdin); freopen("chenhlech.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t --) solve(); return 0; }

Compilation message (stderr)

roz.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
roz.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
roz.cpp:20:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
roz.cpp:20:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
roz.cpp: In function 'int main()':
roz.cpp:60:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |         freopen("chenhlech.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
roz.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen("chenhlech.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#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...