Submission #851699

#TimeUsernameProblemLanguageResultExecution timeMemory
851699vjudge1Bubble Sort 2 (JOI18_bubblesort2)C++17
38 / 100
9097 ms2192 KiB
#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_sum; void pre(){ S_sum.clear(); S_sum.resize(1<<(pr+1)); } void update(int ind){ S_sum[ind]++; while(ind/=2) S_sum[ind]++; } 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_sum[id]; int md=(l+r)/2; return 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+A[i]+1, e_p, s_p, e_p); mx=max(mx, cur); update(s_p+A[i]); } S.push_back(mx); } return S; } //int main(){ // ios_base::sync_with_stdio(0);cin.tie(0); // int n, q; // cin>>n>>q; // vector<int>A(n), X(q), V(q); // for(int i=0;i<n;i++){ // cin>>A[i]; // } // for(int j=0;j<q;j++){ // cin>>X[j]>>V[j]; // } // vector<int>Ans=countScans(A, X, V); // for(int i=0;i<q;i++){ // cout<<Ans[i]<<endl; // } //}

Compilation message (stderr)

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])
      |            ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...