大致的简化题意在我的考试反思里有,裸n2及以上的暴力也不打算再讲了。

 1 #include<cstdio>
 2 #include<ctime>
 3 using namespace std;
 4 #define rus register unsigned short
 5 inline unsigned short max(const rus a,const rus b){return a>b?a:b;}
 6 inline unsigned short min(const rus a,const rus b){return a<b?a:b;}
 7 inline unsigned short read(){
 8     rus a=0;register char ch=getchar();
 9     while(ch<48||ch>57)ch=getchar();
10     while(ch>=48&&ch<=57)a=(a<<3)+(a<<1)+ch-48,ch=getchar();
11     return a;
12 }
13 int ans;
14 unsigned short pos[50005],n;
15 int main(){
16     n=read();
17     for(rus i=1,x,y;i<=n;++i) x=read(),y=read(), pos[x]=y;
18     for(rus i=1,maxx=0,minn=50006;i<=n;++i,maxx=0,minn=50006){
19         if(clock()>990000){printf("%d\n",ans+n-i+1);return 0;}
20         for(rus j=i;j<=n;++j){
21             maxx=max(maxx,pos[j]); minn=min(minn,pos[j]);
22             if(maxx-minn==j-i)ans++;
23         }
24     }
25     
26     printf("%d\n",ans);//printf("%ld\n",clock());
27 }
考场上我的不要脸的n2卡常

相关文章:

  • 2021-11-08
  • 2021-12-15
  • 2021-04-26
  • 2021-10-16
  • 2022-01-02
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
  • 2022-02-05
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
相关资源
相似解决方案