摘要: 看了codeforces上的大神写的题解之后,才知道这道题水的根本!不过相对前面两题来说,这道题的思维要难一点;不过想到了水的根本,这题也真心不难;方法嘛,就像剥洋葱一样,从外面往里面剥;所以呢,dfs,每次往左或者往右找到乱序的那个元素,反转一下;这样就行了,而且题目说了保证能够在三次内搞定;证明我也不会,意思应该就是这样了! 1 #include 2 #include 3 #include 4 #define maxn 1009 5 using namespace std; 6 int a[maxn],n; 7 vectorl,r; 8 bool found=0; 9 int checkl 阅读全文
posted @ 2013-08-27 21:10 Yours1103 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 哎....这次的比赛被安叔骂的好惨!不行呢,要虐回来;这道搜索,老是写错,蛋疼啊!果然是基础没打好! 1 #include 2 using namespace std; 3 int ans[1009],m; 4 bool h[11],flag=true; 5 6 void dfs(int n,int ch,int x) 7 { 8 if(n>m) 9 {10 flag=false;11 printf("YES\n");12 for(int i=0; i<n; ++i)13 printf(" %d",ans... 阅读全文
posted @ 2013-08-27 11:15 Yours1103 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 这题也是一个线段树的水题;不过开始题目没看明白,害得我敲了一个好复杂的程序。蛋疼啊。。。。最后十几分钟的时候突然领悟到了题意,但是还是漏掉一个细节,老是过不去。。。以后比赛的时候不喝啤酒了,再也不喝了。。。。贴上代码: 1 #include 2 #include 3 #define maxn 262200 4 using namespace std; 5 6 struct tree 7 { 8 int num; 9 int l,r;10 tree *left,*right;11 } tr[maxn];12 int nodecount=0,a;13 14 void up... 阅读全文
posted @ 2013-08-27 09:46 Yours1103 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 也是水题一个,不过稍微要细心点。。。。贴代码: 1 #include 2 using namespace std; 3 long long n,m; 4 long long ans=0; 5 int main() 6 { 7 long long s=0,t; 8 cin>>n>>m; 9 cin>>s;10 ans=s-1;11 for(int i=1;i>t;14 if(t<s)15 ans+=(n-s+t);16 else ans+=(t-s);17 s=t;18 }19... 阅读全文
posted @ 2013-08-27 09:42 Yours1103 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 水题一个;直接贴代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 char s[110]; 6 int num[100]; 7 int main() 8 { 9 int cnt=0;10 scanf("%s",s);11 for(int i=0;i<strlen(s);i++)12 {13 if(s[i]!='+')14 num[cnt++]=s[i]-'0';15 }16 if(cnt==0) {printf("\n");return 0;. 阅读全文
posted @ 2013-08-27 09:40 Yours1103 阅读(134) 评论(0) 推荐(0) 编辑