#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
int pr=15, s_p=1<<pr, e_p=(1<<(pr+1))-1;
int n;
vector<int>S_mx;
void pre(){
S_mx.clear();
S_mx.resize(1<<(pr+1));
}
void update(int ind, int c){
S_mx[ind]=max(S_mx[ind], c);
while(ind/=2)
S_mx[ind]=max(S_mx[ind], c);
}
int get(int id, int u, int v, int l, int r){
if(l>v || r<u)
return 0;
if(l>=u && r<=v)
return S_mx[id];
int md=(l+r)/2;
return max(get(id*2, u, v, l, md), get(id*2+1, u, v, md+1, r));
}
vector<int> countScans(vector<int>A, vector<int>X, vector<int>V){
vector<int>S, All;
n=A.size();
int q=X.size();
for(int i=0;i<n;i++){
All.push_back(A[i]);
}
for(int i=0;i<q;i++){
All.push_back(V[i]);
}
sort(all(All));
int cur=1;
map<int, int>mp;
for(int i=0;i<All.size();i++){
if(i==All.size()-1 || All[i]!=All[i+1])
mp[All[i]]=cur++;
}
for(int i=0;i<n;i++){
A[i]=mp[A[i]];
}
for(int k=0;k<q;k++){
pre();
A[X[k]]=mp[V[k]];
int mx=0;
for(int i=0;i<n;i++){
int cur=get(1, s_p, s_p+A[i]-1, s_p, e_p)+1;
mx=max(mx, cur);
update(s_p+A[i], cur);
}
S.push_back(mx);
}
return S;
}
Compilation message
bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:145:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
145 | for(int i=0;i<All.size();i++){
| ~^~~~~~~~~~~
bubblesort2.cpp:146:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
146 | if(i==All.size()-1 || All[i]!=All[i+1])
| ~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5779 ms |
1172 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |