제출 #417367

#제출 시각아이디문제언어결과실행 시간메모리
417367nvmdavaBubble Sort 2 (JOI18_bubblesort2)C++17
100 / 100
2981 ms51412 KiB
#include "bubblesort2.h" #include <bits/stdc++.h> using namespace std; const int BIG = 100'000'000; vector<pair<int, int> > val; int seg[5'000'000], lz[5'000'000]; void pushdown(int id, int l, int r){ seg[id] += lz[id]; if(l != r){ lz[id << 1] += lz[id]; lz[id << 1 | 1] += lz[id]; } lz[id] = 0; } void update(int id, int l, int r, int L, int R, int x){ if(L <= l && r <= R){ lz[id] += x; pushdown(id, l, r); return; } pushdown(id, l, r); if(R < l || r < L) return; int m = (l + r) >> 1; update(id << 1, l, m, L, R, x); update(id << 1 | 1, m + 1, r, L, R, x); seg[id] = max(seg[id << 1], seg[id << 1 | 1]); } vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){ lz[1] = -BIG; for(int i = 0; i < A.size(); ++i) val.push_back({A[i], i}); for(int i = 0; i < X.size(); ++i) val.push_back({V[i], X[i]}); sort(val.begin(), val.end()); val.erase(unique(val.begin(), val.end()), val.end()); for(int i = 0; i < A.size(); ++i) A[i] = upper_bound(val.begin(), val.end(), make_pair(A[i], i)) - val.begin(); for(int i = 0; i < X.size(); ++i) V[i] = upper_bound(val.begin(), val.end(), make_pair(V[i], X[i])) - val.begin(); for(int i = 0; i < A.size(); ++i){ update(1, 1, val.size(), A[i] + 1, val.size(), -1); update(1, 1, val.size(), A[i], A[i], i + BIG); } vector<int> answer(X.size()); for (int i = 0; i < X.size(); ++i) { update(1, 1, val.size(), A[X[i]] + 1, val.size(), 1); update(1, 1, val.size(), A[X[i]], A[X[i]], - BIG - X[i]); A[X[i]] = V[i]; update(1, 1, val.size(), A[X[i]] + 1, val.size(), -1); update(1, 1, val.size(), A[X[i]], A[X[i]], X[i] + BIG); answer[i]=seg[1]; } return answer; }

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

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for(int i = 0; i < A.size(); ++i)
      |                 ~~^~~~~~~~~~
bubblesort2.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i = 0; i < X.size(); ++i)
      |                 ~~^~~~~~~~~~
bubblesort2.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for(int i = 0; i < A.size(); ++i)
      |                 ~~^~~~~~~~~~
bubblesort2.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |  for(int i = 0; i < X.size(); ++i)
      |                 ~~^~~~~~~~~~
bubblesort2.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for(int i = 0; i < A.size(); ++i){
      |                 ~~^~~~~~~~~~
bubblesort2.cpp:55:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for (int i = 0; i < X.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...