제출 #222360

#제출 시각아이디문제언어결과실행 시간메모리
222360shenxyGrudanje (COCI19_grudanje)C++11
35 / 70
2109 ms246124 KiB
#include <iostream> #include <algorithm> using namespace std; typedef pair<int, int> ii; struct seg { int s, e, m; ii v; seg *l, *r; seg(int _s, int _e) { s = _s, e = _e, m = (s + e) / 2; if (s != e) { l = new seg(s, m); r = new seg(m + 1, e); v.first = max((l -> v).first, (r -> v).first); v.second = max(min((l -> v).first, (r -> v).first), max((l -> v).second, (r -> v).second)); } else v = ii(0, 0); } void update(int i, int dv) { if (s == e) { v.first = dv; return; } else if (i > m) r -> update(i, dv); else l -> update(i, dv); v.first = max((l -> v).first, (r -> v).first); v.second = max(min((l -> v).first, (r -> v).first), max((l -> v).second, (r -> v).second)); } ii query(int a, int b) { if (s == a && e == b) return v; if (a > m) return r -> query(a, b); if (b <= m) return l -> query(a, b); ii x = l -> query(a, m), y = r -> query(m + 1, b); return ii(max(x.first, y.first), max(min(x.first, y.first), max(x.second, y.second))); } } *root[26]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string S; cin >> S; int Q; cin >> Q; int a[Q], b[Q], p[S.size()], ans = 0; for (int i = 0; i < Q; ++i) cin >> a[i] >> b[i]; for (int i = 0; i < S.size(); ++i) cin >> p[i]; for (int i = 0; i < 26; ++i) root[i] = new seg(0, S.size() - 1); for (int i = 0; i < S.size(); ++i) root[S[i] - 'a'] -> update(i, p[i]); for (int i = 0; i < Q; ++i) { for (int j = 0; j < 26; ++j) ans = max(ans, (root[j] -> query(a[i] - 1, b[i] - 1)).second); } printf("%d", ans); return 0; }

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

grudanje.cpp: In function 'int main()':
grudanje.cpp:45:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < S.size(); ++i) cin >> p[i];
                  ~~^~~~~~~~~~
grudanje.cpp:47:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < S.size(); ++i) root[S[i] - 'a'] -> update(i, p[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...