# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
885100 | txk_2k6 | Difference (POI11_roz) | C++17 | 3182 ms | 65536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define NAME "ssdiff"
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
using ll = long long;
using pii = pair<int, int>;
void file(){
freopen(NAME".inp","r",stdin);
freopen(NAME".out","w",stdout);
}
int n;
string s;
const int mx=1e6+5;
int dp[30][mx];
int check(int u, int v){
int mx=0, mn=v-u+1;
for (int i=1; i<='z'-'a'+1; i++){
int d=dp[i][v]-dp[i][u];
mx=max(mx,d);
if (d!=0) mn=min(mn,d);
}
cout << u<<' '<<v<<' '<<mx<<' '<<mn<<' '<<mx-mn<<'\n';
if (mn>mx) return mx;
else return mx-mn;
}
int main(){
//file();
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin >> n >> s;
s=" "+s;
for (int i=1; i<='z'-'a'+1; i++) dp[0][i]=0;
for (int i=1; i<=n; i++){
for (int j=1; j<='z'-'a'+1; j++){
dp[j][i]=dp[j][i-1];
}
dp[s[i]-'a'+1][i]++;
}
int res=0;
for (int i=0; i<n; i++){
for (int j=i+1; j<=n; j++){
res=max(res,check(i,j));
}
}
cout << res<<'\n';
return 0;
}
Compilation message (stderr)
# | 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... |
# | 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... |