제출 #464540

#제출 시각아이디문제언어결과실행 시간메모리
464540prvocislo새로운 문제 (POI11_roz)C++17
60 / 100
151 ms65540 KiB
#include <iostream> #include <vector> #include <set> #include <algorithm> using namespace std; int ans = 0; void solve(const vector<int>& v) // v je indexovane od 1 { int last_minus_one = -1; vector<int> pf(v.size(), 0), pf_min(v.size(), 0); // prefixove sucty, najmensi prefix doteraz for (int i = 1; i < v.size(); i++) { pf[i] = pf[i - 1] + v[i]; pf_min[i] = min(pf_min[i - 1], pf[i]); } for (int i = 1; i < v.size(); i++) { if (v[i] == -1) last_minus_one = i; if (last_minus_one != -1) ans = max(ans, pf[i] - pf_min[last_minus_one - 1]); } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; vector<vector<vector<int> > > v(26, vector<vector<int> >(26, { 0 })); for (int i = 0; i < n; i++) { for (int j = 0; j < 26; j++) if (j != s[i] - 'a') { v[s[i] - 'a'][j].push_back(1); v[j][s[i] - 'a'].push_back(-1); } } for (int i = 0; i < 26; i++) for (int j = 0; j < 26; j++) if (j != i) solve(v[i][j]); cout << ans << "\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

roz.cpp: In function 'void solve(const std::vector<int>&)':
roz.cpp:12:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for (int i = 1; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
roz.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = 1; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
#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...