Submission #377024

#TimeUsernameProblemLanguageResultExecution timeMemory
377024SavicSDifference (POI11_roz)C++14
0 / 100
70 ms65540 KiB
#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ff(i,a,b) for(int i=a;i<=b;i++) #define fb(i,b,a) for(int i=b;i>=a;i--) using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int,int> pii; const int maxn = 1000005; const int inf = 1e9 + 5; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // os.order_of_key(k) the number of elements in the os less than k // *os.find_by_order(k) print the k-th smallest number in os(0-based) int n; string s; vector<int> vec[maxn]; int pref[maxn][26]; int main() { ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); cin >> n >> s; s = ' ' + s; ff(i,1,n){ vec[s[i] - 'a'].pb(i); pref[i][s[i] - 'a'] += 1; ff(j,0,25)pref[i][j] += pref[i - 1][j]; } // ne moze ovako treba ono koje se najvise i najmanje pojavljuje int rez = 0; ff(a,0,25){ // za slovo a if(vec[a].empty())continue; ff(b,0,25){ if(vec[b].empty() || a == b)continue; int mn = 0; ff(i,0,sz(vec[a]) - 1){ int id = vec[a][i]; int kol = i + 1 - pref[id][b] - mn; rez = max(rez, kol); mn = min(mn, i + 1 - pref[id][b]); } } } cout << rez << endl; return 0; } /** // probati bojenje sahovski ili slicno **/
#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...