版本比较
勰码金牌学院 S1 课程 2. ST表
正文
增加 1 行删除 141 行
46 行未改动4748495051525354555657585960616263646566676869707172737447 行未改动12212312412512612712812913013113213313413513613713813914014114214314414514614714814915015143 行未改动19519619719819920020120220320420520620720820921021121221321421554 行未改动27027127227327427527627727827928028128228328428528628728828929029129229329429529629729829952 行未改动35235335435535635735835936036136236336436536636736836937037137237337437537637737837934 行未改动41441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444583 行未改动52953053153253353453553653753853954054154254354454554654754854955055155255355455555655755861 行未改动46 行未改动典中典。```cpp#include<iostream>#include<cstdio>#include<cmath>#define re register#define endl '\n'#define ll long long#define ull unsigned long long#define db double#define fi const int&#define fl const ll&#define fc const char&#define fs const string&#define debug() puts("I Love Hina Forever")using namespace std ;namespace IO {template<class T>inline void read(T &x){char c=getchar(),f=false;x=0;while(c<48||c>57) {f|=(c==45),c=getchar();}while(c>=48&&c<=57){x=(x<<3)+(x<<1)+(c^48),c=getchar();}if(f){x=~x+1;}}template<class T,class ...Arg>inline void read(T &x,Arg &...arg){read(x),read(arg...);}template<class T>inline void nout(T x){if(x<0){putchar(45),x=~x+1;}if(x>9){nout(x/10);}putchar(x%10|48);}template<class T>inline void write(T x,fc c){nout(x),putchar(c);}}using namespace IO ;const int N = 5e4 + 2 ;int n,q,a[N],maxx[N][35],minn[N][35],lg[N] ;inline void init () {for (re int i = 1 ; i <= n ; ++i) maxx[i][0] = minn[i][0] = a[i] ;47 行未改动答案为 $ans$ 中 $1$ 的个数。```cpp#include<iostream>#include<cstdio>#include<unordered_map>#include<bitset>#define re register#define endl '\n'#define ll long long#define ull unsigned long long#define db double#define fi const int&#define fl const ll&#define ful const ull&#define fc const char&#define fs const string&#define debug() puts("I Love Hina Forever")using namespace std ;namespace IO {template<class T>inline void read(T &x){char c=getchar(),f=false;x=0;while(c<48||c>57) {f|=(c==45),c=getchar();}while(c>=48&&c<=57){x=(x<<3)+(x<<1)+(c^48),c=getchar();}if(f){x=~x+1;}}template<class T,class ...Arg>inline void read(T &x,Arg &...arg){read(x),read(arg...);}template<class T>inline void nout(T x){if(x<0){putchar(45),x=~x+1;}if(x>9){nout(x/10);}putchar(x%10|48);}template<class T>inline void write(T x,fc c){nout(x),putchar(c);}}using namespace IO ;const int N = 5e5 + 2 ;int n,m,d,q ;int lg[N],p[N] ;ll a[N],b[62] ;43 行未改动明显贪心,小奥的知识就可以解决了。```cpp#include<iostream>#include<cstdio>#include<string>#define ll long long#define re register#define endl '\n'using namespace std ;namespace IO {template<class T>inline void read(T &x){char c=getchar(),f=false;x=0;while(c<48||c>57) {f|=(c==45),c=getchar();}while(c>=48&&c<=57){x=(x<<3)+(x<<1)+(c^48),c=getchar();}if(f){x=~x+1;}}template<class T,class ...Arg>inline void read(T &x,Arg &...arg){read(x),read(arg...);}template<class T>inline void nout(T x){if(x<0){putchar(45),x=~x+1;}if(x>9){nout(x/10);}putchar(x%10|48);}template<class T>inline void write(T x,const char &c){nout(x),putchar(c);}}using namespace IO ;string s,ans ;int k,n,len ;inline int findi (int num,int id) {for (re int i = id ; i <= n ; ++i) {54 行未改动时间 $O(n \log^2n)$,瓶颈在于预处理。```cpp#include<iostream>#include<cstdio>#include<unordered_map>#include<algorithm>#define re register#define endl '\n'#define ll long long#define ull unsigned long long#define db double#define fi const int&#define fl const ll&#define ful const ull&#define fc const char&#define fs const string&#define debug() puts("I Love Hina Forever")using namespace std ;namespace IO {template<class T>inline void read(T &x){char c=getchar(),f=false;x=0;while(c<48||c>57) {f|=(c==45),c=getchar();}while(c>=48&&c<=57){x=(x<<3)+(x<<1)+(c^48),c=getchar();}if(f){x=~x+1;}}template<class T,class ...Arg>inline void read(T &x,Arg &...arg){read(x),read(arg...);}template<class T>inline void nout(T x){if(x<0){putchar(45),x=~x+1;}if(x>9){nout(x/10);}putchar(x%10|48);}template<class T>inline void write(T x,fc c){nout(x),putchar(c);}}using namespace IO ;const int N = 1e5 + 2 ;int n,m,T ;int a[N],lg[N],f[N][31] ;unordered_map<int,ll> cnt ;52 行未改动$O(n \log n)$,瓶颈预处理。```cpp#include<iostream>#include<cstdio>#define re register#define endl '\n'#define ll long long#define ull unsigned long long#define db double#define fi const int&#define fl const ll&#define ful const ull&#define fc const char&#define fs const string&#define debug() puts("I Love Hina Forever")using namespace std ;namespace IO {template<class T>inline void read(T &x){char c=getchar(),f=false;x=0;while(c<48||c>57) {f|=(c==45),c=getchar();}while(c>=48&&c<=57){x=(x<<3)+(x<<1)+(c^48),c=getchar();}if(f){x=~x+1;}}template<class T,class ...Arg>inline void read(T &x,Arg &...arg){read(x),read(arg...);}template<class T>inline void nout(T x){if(x<0){putchar(45),x=~x+1;}if(x>9){nout(x/10);}putchar(x%10|48);}template<class T>inline void write(T x,fc c){nout(x),putchar(c);}}using namespace IO ;const int N = 1e5 + 2 ;int T,n,k ;int a[N],fax[N][32],fin[N][32],lg[N] ;inline void init () {34 行未改动```## [2. MarsOJ P1860. CGCDSSQ](https://marsoj.cn/p/P1860)简化版 [4. MarsOJ P1858. GCD](https://marsoj.cn/p/P1858)。```cpp#include<iostream>#include<cstdio>#include<unordered_map>#define re register#define endl '\n'#define ll long long#define ull unsigned long long#define db double#define fi const int&#define fl const ll&#define ful const ull&#define fc const char&#define fs const string&#define debug() puts("I Love Hina Forever")using namespace std ;namespace IO {template<class T>inline void read(T &x){char c=getchar(),f=false;x=0;while(c<48||c>57) {f|=(c==45),c=getchar();}while(c>=48&&c<=57){x=(x<<3)+(x<<1)+(c^48),c=getchar();}if(f){x=~x+1;}}template<class T,class ...Arg>inline void read(T &x,Arg &...arg){read(x),read(arg...);}template<class T>inline void nout(T x){if(x<0){putchar(45),x=~x+1;}if(x>9){nout(x/10);}putchar(x%10|48);}template<class T>inline void write(T x,fc c){nout(x),putchar(c);}}using namespace IO ;const int N = 1e5 + 2 ;int n,q,x ;int a[N],f[N][32],lg[N] ;unordered_map<int,ll> cnt ;83 行未改动否则查 $(l,r)$ 是否都 $<d_y$,真为 `maybe`,假为 `false`。```cpp#include<iostream>#include<cstdio>#include<unordered_map>#include<algorithm>#define re register#define endl '\n'#define ll long long#define ull unsigned long long#define db double#define fi const int&#define fl const ll&#define ful const ull&#define fc const char&#define fs const string&#define debug() puts("I Love Hina Forever")using namespace std ;namespace IO {template<class T>inline void read(T &x){char c=getchar(),f=false;x=0;while(c<48||c>57) {f|=(c==45),c=getchar();}while(c>=48&&c<=57){x=(x<<3)+(x<<1)+(c^48),c=getchar();}if(f){x=~x+1;}}template<class T,class ...Arg>inline void read(T &x,Arg &...arg){read(x),read(arg...);}template<class T>inline void nout(T x){if(x<0){putchar(45),x=~x+1;}if(x>9){nout(x/10);}putchar(x%10|48);}template<class T>inline void write(T x,fc c){nout(x),putchar(c);}}using namespace IO ;const int N = 5e4 + 2 ;int n,q ;int y[N],d[N],f[N][32],lg[N] ;unordered_map<int,bool> vis ;61 行未改动46 行未改动474849505152535447 行未改动10210310410510610710810943 行未改动15315415515615715815916054 行未改动21521621721821922022122252 行未改动27527627727827928028128234 行未改动31731831932032132232332432532632783 行未改动41141241341441541641741861 行未改动46 行未改动典中典。```cppconst int N = 5e4 + 2 ;int n,q,a[N],maxx[N][35],minn[N][35],lg[N] ;inline void init () {for (re int i = 1 ; i <= n ; ++i) maxx[i][0] = minn[i][0] = a[i] ;47 行未改动答案为 $ans$ 中 $1$ 的个数。```cppconst int N = 5e5 + 2 ;int n,m,d,q ;int lg[N],p[N] ;ll a[N],b[62] ;43 行未改动明显贪心,小奥的知识就可以解决了。```cppstring s,ans ;int k,n,len ;inline int findi (int num,int id) {for (re int i = id ; i <= n ; ++i) {54 行未改动时间 $O(n \log^2n)$,瓶颈在于预处理。```cppconst int N = 1e5 + 2 ;int n,m,T ;int a[N],lg[N],f[N][31] ;unordered_map<int,ll> cnt ;52 行未改动$O(n \log n)$,瓶颈预处理。```cppconst int N = 1e5 + 2 ;int T,n,k ;int a[N],fax[N][32],fin[N][32],lg[N] ;inline void init () {34 行未改动```## [2. MarsOJ P1860. CGCDSSQ](https://marsoj.cn/p/P1860)简化版 [MarsOJ P1858](https://marsoj.cn/p/P1858)。```cppconst int N = 1e5 + 2 ;int n,q,x ;int a[N],f[N][32],lg[N] ;unordered_map<int,ll> cnt ;83 行未改动否则查 $(l,r)$ 是否都 $<d_y$,真为 `maybe`,假为 `false`。```cppconst int N = 5e4 + 2 ;int n,q ;int y[N],d[N],f[N][32],lg[N] ;unordered_map<int,bool> vis ;61 行未改动