poj3617 Best Cow Line
来源:互联网 发布:幼儿园网络研修的简报 编辑:程序博客网 时间:2024/06/05 08:57
/*比较需要注意的是这句话* Every line (except perhaps the last one) contains the initials of 80 cows ('A'..'Z') in the new line. 没有特殊处理格式的话,就很容易导致PE*/#include <iostream>using namespace std;int N;const int MAX_N = 2005;char S[MAX_N + 1];void solve(){//剩余字符串S[i]中,i的取值范围为[a,b] int a = 0, b = N - 1;int ans = 0;while (a <= b){//将从左起和从右起的字符串比较bool left = false;for (int i = 0; a + i <= b; i++){if ( S[a + i] < S[b - i] ){left = true;break;}else if ( S[a + i] > S[b - i] ){left = false;break;}}if (left) cout << S[a++];else cout << S[b--];ans++;if (ans % 80 == 0 && ans < N - 1) cout << endl; }cout << endl;}int main(){cin >> N;for (int i = 0; i < N; i++) cin >> S[i]; solve();return 0;}
阅读全文
0 0
- POJ3617 Best Cow Line
- POJ3617 Best Cow Line
- POJ3617 Best Cow Line
- best cow line(poj3617)
- POJ3617-Best Cow Line
- POJ3617 Best Cow Line
- POJ3617 Best Cow Line
- poj3617 Best Cow Line
- POJ3617 Best Cow Line
- POJ3617-Best Cow Line
- poj3617 Best Cow Line
- poj3617 Best Cow Line
- POJ3617 Best Cow Line
- POJ3617 Best Cow Line
- poj3617 Best Cow Line 贪心
- POJ3617 Best Cow Line 贪心
- poj3617 Best Cow Line 贪心
- poj3617 Best Cow Line 贪心
- L
- 【DP】回文的最小分割数
- poj1852 Ants
- C 语言各个数据类型所占字节数
- oracle中like总结
- poj3617 Best Cow Line
- IIS WebService 内存溢出问题的修改过程
- 【leetcode】38. Count and Say(Python & C++)
- 找出1000以内的完全数。
- spring boot 开发热部署配置 (idea IDE)
- TabLayout使用
- C#基础-006(2)if练习 如果一个数是3的倍数 那么就输出"过" 否则输出该数
- java String类计算HashCode散列码的方法
- 封装Map 用于不同项目之间传值