Submission #885112

#TimeUsernameProblemLanguageResultExecution timeMemory
885112vjudge1새로운 문제 (POI11_roz)C++17
100 / 100
582 ms13572 KiB
// Author : Hoang Van Tra - HSGS Bac Giang // Train VOI 2023 - 2024 #include <bits/stdc++.h> using namespace std; // -------------------------------------------------------INDEF----------------------------------------------------------------------- #define For(i,a,b) for(int i = a; i <= b; i++) #define Ford(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define ii pair<int,int> #define fi first #define se second #define pb push_back #define all(v) v.begin(),v.end() #define RRH(v) v.resize(unique(all(v)) - v.begin()) const int N = 1e6+7; const int M = 1e9+7; const ll oo = 1e18; const int block = 708; int n; vector<int> id[30]; string s; // -------------------------------------------------------ENDEF---------------------------------------------------------------------- int32_t main() { ios::sync_with_stdio(0); cin.tie(0); #define TASK "ssdiff" if (fopen (".inp", "r")) { freopen (".inp", "r", stdin); freopen (".out", "w", stdout); } if(fopen(TASK".inp", "r")) { freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout); } cin >> n >> s; s = " " + s; For(i, 1, n) { id[s[i] - 'a'].push_back(i); } int res = 0; for (int x = 0; x < 26; x++) { for (int y = 0; y < 26; y++) { if (id[x].empty() || id[y].empty()) continue; if (x == y) continue; vector<int> a {0}; int j = 0; for (int i: id[x]) { while (j < id[y].size() && id[y][j] < i) { a.push_back(-1); j++; } a.push_back(1); } while (j < id[y].size()) { a.push_back(-1); j++; } int ans = 0, mini = M, last = 0; vector<int> pre (a.size(), 0); for (int i = 1; i < a.size(); i++) { pre[i] = pre[i - 1] + a[i]; if (i > 1 && a[i] != a[i - 1]) { for (int j = last; j < i - 1; j++) { mini = min(mini, pre[j]); } last = i - 1; } ans = max(ans, pre[i] - mini); } res = max(res, ans); } } cout << res; return 0; }

Compilation message (stderr)

roz.cpp: In function 'int32_t main()':
roz.cpp:56:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |                 while (j < id[y].size() && id[y][j] < i) {
      |                        ~~^~~~~~~~~~~~~~
roz.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             while (j < id[y].size()) {
      |                    ~~^~~~~~~~~~~~~~
roz.cpp:68:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |             for (int i = 1; i < a.size(); i++) {
      |                             ~~^~~~~~~~~~
roz.cpp:34:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen (".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~
roz.cpp:35:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen (".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
roz.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen(TASK".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
roz.cpp:39:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         freopen(TASK".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...