제출 #534303

#제출 시각아이디문제언어결과실행 시간메모리
534303ac2hu무제 (POI11_tem)C++14
24 / 100
190 ms35804 KiB
#include <bits/stdc++.h> #ifdef DEBUG #include "../templates/debug.h" #else #define deb(x...) #endif using namespace std; template <class T> struct SparseTable { std::vector<T> v; std::vector<std::vector<short>> jump; int level(int x) { return 31 - __builtin_clz(x); } int comb(int a, int b) { return v[a] == v[b] ? std::max(a, b) : (v[a] > v[b] ? a : b); } void init(const std::vector<T>& _v) { v = _v; jump = {std::vector<short>((int)v.size())}; iota(jump[0].begin(), jump[0].end(), 0); for (int j = 1; (1 << j) <= (int)v.size(); j++) { jump.push_back(std::vector<short>((int)v.size() - (1 << j) + 1)); for (int i = 0; i < (int)jump[j].size(); i++) { jump[j][i] = comb(jump[j - 1][i], jump[j - 1][i + (1 << (j - 1))]); } } } int index(int l, int r) { assert(l <= r); int d = level(r - l + 1); return comb(jump[d][l], jump[d][r - (1 << d) + 1]); } T query(int l, int r) { return v[index(l, r)]; } }; signed main() { iostream::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int n;cin >> n; vector<pair<int,int>> a(n); for(auto &e : a)cin >> e.first >> e.second; vector<int> temp(n); for(int i = 0;i<n;i++) temp[i] = a[i].first; SparseTable<int> rq; rq.init(temp); vector<int> leftmost(n); for(int i =0;i<n;i++){ int l = 0,r = i; while(l < r){ int mid = (l + r)/2; if(rq.query(mid,i) <= a[i].second) r = mid; else l = mid + 1; } leftmost[i] = l; } for(int i = 1;i<leftmost.size();i++) leftmost[i] = max(leftmost[i], leftmost[i - 1]); for(int i = 0;i<n;i++) leftmost[i] = i - leftmost[i] + 1; deb(leftmost); cout << *max_element(leftmost.begin(),leftmost.end()); }

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

tem.cpp: In function 'int main()':
tem.cpp:63:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |  for(int i = 1;i<leftmost.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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...