标签:cstring turn include 技术 efault site lap bsp close
//题目真的杂T T
https://www.luogu.org/problem/show?pid=3719
题目剧毒吧,注意读入(写挂n次)。
模拟。
1 #include<cstdio> 2 #define Max(a,b) (a>b?a:b) 3 using namespace std; 4 int cxsb(){ 5 int maxx=0,cnt=0; 6 while(1){ 7 char ch=getchar(); 8 switch(ch){ 9 case ‘a‘:{cnt++;break;} 10 case ‘(‘:{cnt+=cxsb();break;} 11 case ‘)‘:{maxx=Max(maxx,cnt);return maxx;} 12 case ‘|‘:{maxx=Max(maxx,cnt);cnt=0;break;} 13 default :{maxx=Max(maxx,cnt);return maxx;} 14 } 15 } 16 } 17 int main(){ 18 printf("%d",cxsb()); 19 return 0; 20 }
https://www.luogu.org/problem/show?pid=1160
双向链表。
1 #include<cstdio> 2 #include<cstring> 3 #define MAXN 100005 4 using namespace std; 5 int n; 6 bool visited[MAXN]; 7 struct queue{ 8 int l,r,id; 9 }q[MAXN]; 10 int main(){ 11 scanf("%d",&n); 12 q[1]=(queue){0,0,1}; 13 for(int i=2;i<=n;i++){ 14 int k,p;scanf("%d%d",&k,&p); 15 if(p==0){ 16 q[i].l=q[k].l,q[i].r=k; 17 q[q[i].l].r=i; 18 q[q[i].r].l=i; 19 }else{ 20 q[i].l=k,q[i].r=q[k].r; 21 q[q[i].l].r=i; 22 q[q[i].r].l=i; 23 } 24 q[i].id=i; 25 } 26 int m;scanf("%d",&m); 27 memset(visited,0,sizeof(visited)); 28 while(m--){ 29 int x;scanf("%d",&x); 30 if(visited[x]) continue ; 31 q[q[x].l].r=q[x].r; 32 q[q[x].r].l=q[x].l; 33 visited[x]=true; 34 } 35 int now=q[0].r; 36 while(now!=0) { 37 printf("%d ",q[now].id); 38 now=q[now].r; 39 } 40 return 0; 41 }
标签:cstring turn include 技术 efault site lap bsp close
原文地址:http://www.cnblogs.com/drizzly/p/7712633.html