一行盒子 (模拟) 13年湖南省赛题
来源:互联网 发布:域名需要实名认证吗 编辑:程序博客网 时间:2024/05/31 06:22
好伤心啊 wocao 这道题模拟了两个半小时 最后全错 因为不知道数组模拟链表的时候 自交了!!
哇 好伤心 好挫败 写个数组模拟链表写不出来 磨磨蹭蹭 最后还是错的 还是”参考”了刘汝佳神犇的代码
……..
前面的都是废话
一开始 哇 我写的一塌糊涂
a[p1r].l=p1l; 比如这一句,意思是把p1左边的左边和p1右边相连
p1l—-p1——p1r
意思就是把图中的p1去了 把旁边两个相连
哇 之前的代码就是
int temp=p1-1;
a[p1-1].l=temp;
我真的佩服我自己 9999(6翻了)
#include<cstdio>#include<cstring>const int maxn=100005;struct note{ int l,r;} a[maxn];int p1,p2,p;typedef long long ll;ll n,m;void solve_l()//交换到y左边{ int p1l=a[p1].l; int p1r=a[p1].r; int p2l=a[p2].l; int p2r=a[p2].r; if(p2l==p1)return; a[p1l].r=p1r; a[p1r].l=p1l; a[p1].l=p2l; a[p2l].r=p1; a[p1].r=p2; a[p2].l=p1;}void solve_r()//交换到y右边{ int p1l=a[p1].l; int p1r=a[p1].r; int p2l=a[p2].l; int p2r=a[p2].r; if(p2r==p1)return; a[p1l].r=p1r; a[p1r].l=p1l; a[p1].l=p2; a[p2].r=p1; a[p1].r=p2r; a[p2r].l=p1;}void solve_c()//两个相互交换{ int p1l=a[p1].l; int p1r=a[p1].r; int p2l=a[p2].l; int p2r=a[p2].r; if(a[p1].r==p2)///避免自环 { a[p2].l=p1l; a[p1l].r=p2; a[p1].r=p2r; a[p2r].l=p1; a[p2].r=p1; a[p1].l=p2; return ; } a[p1l].r=p2; a[p2].l=p1l; a[p2].r=p1r; a[p1r].l=p2; a[p2l].r=p1; a[p1].l=p2l; a[p2r].l=p1; a[p1].r=p2r;}int main(){ int coun=1; freopen("in1.txt","r",stdin); while(scanf("%lld%lld",&n,&m)!=-1) { for(int i=1; i<=n; i++) { a[i].l=i-1; a[i].r=i+1; } a[0].l=n; a[0].r=1; a[n].r=0; bool der=false; while(m--) { scanf("%d",&p); if(p==4)der=!der; else { scanf("%d%d",&p1,&p2); if(p == 3 && a[p2].r==p1) p1^=p2^=p1^=p2;///避免自环 if(p != 3 && der) p = 3 - p; if(p == 1 && p1==a[p2].l) continue; if(p == 2 && p1==a[p2].r) continue; if(p==1)solve_l(); else if(p==2)solve_r(); else if(p==3)solve_c(); } } int x=0; ll sum=0; for(int i=1; i<=n; i++) { x=a[x].r; if(i&1)sum+=((ll)x); } if((der)&&(!(n&1))){ sum=(n*(n+1)/2ll)-sum;///这里加了个long long WA! } printf("Case %d: %lld\n",coun++,sum); } return 0;}
1 0
- 一行盒子 (模拟) 13年湖南省赛题
- 一行盒子 (湖南省第九届大学生程序设计大赛原题)
- 湖南程序设计真题 一行盒子 (链表模拟)
- CSU1329 一行盒子(模拟链表)
- 2011年湖南省第七届大学生计算机程序设计竞赛,E题,盒子游戏
- 一行盒子
- 1329: 一行盒子+csuoj+数组模拟链表
- csu 1329 一行盒子(双向链表模拟)
- CSUOJ 1329 一行盒子(数组模拟链表)
- csu 1329 一行盒子(数组模拟链表)
- CSU 1329 一行盒子(模拟链表)
- CSU 1329~一行盒子(模拟链表)
- CSU OJ:1329 一行盒子(模拟链表)
- 2016年湖南省省赛A题
- 湖南省赛A题
- (双向链表之数组模拟)Boxes in a Line,第九届湖南省赛,B题
- 2016湖南省赛G题。
- CSU 1329 一行盒子
- mysql case 使用方法
- [DevExpress]DevExpress XtraTabControl 加载Form
- String path = request.getContextPath();获取应用的上下文路径。
- IOS开发证书变成“此证书的签发者无效”解决方法
- python爬虫(一)
- 一行盒子 (模拟) 13年湖南省赛题
- python 文本处理(分割)
- 项目开源的步骤
- ubuntu下安装boost环境
- 十大滤波算法程序大全(Arduino精编无错版)
- 代理模式(一):代理模式概述,代理模式结构与实现
- document.all.item().style.display的意思
- python爬虫(二)之get请求
- 帝国cms总结