POJ3617 Best Cow Line
来源:互联网 发布:域名管理系统dns 编辑:程序博客网 时间:2024/06/05 14:32
注意最后输出的时候每80个就要换一次行(PE两次后的教训之认真看题)
#include <cstdio>#include <iostream>#include <algorithm>#include <cstring>using namespace std;int n;char s[20000],T[20000];int main(){ scanf("%d",&n); for(int i = 1; i <= n; i ++) { cin>>s[i]; } int l = 1,r = n,i=1; while(l!=r) { if(s[l]-'A' < s[r]-'A') { T[i] = s[l]; l ++; } else if(s[l]-'A' > s[r]-'A') { T[i] = s[r]; r--; } else { int ll = l; int rr = r; while(s[ll] == s[rr]) { ll++; rr--; } if(s[ll]-'A' < s[rr]-'A') { T[i] = s[l]; l ++; } else { T[i] = s[r]; r--; } } i++; } T[i] = s[l]; for(int i = 1; i <= n; i ++) { if(i%80 != 0) cout <<T[i]; else cout <<T[i]<<endl; } return 0;}
阅读全文
1 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 贪心
- 现代OpenGL+Qt学习笔记之十一:使用halfway向量提高光照计算效率
- 我的博客之路
- 三角形的判断
- Unity3D -- 图形 -- 向量运算
- Python学习笔记: 增强的格式化字符串format函数
- POJ3617 Best Cow Line
- 概率机器人的置信度
- 类与对象第六题
- 用“埃氏筛法”求2~10000以内的素数。2~100以内的数,先去掉2的倍数,再去掉3的倍数,再去掉5的倍数,……依此类推,最后剩下的就是素数。
- 强符号和弱符号
- 简单操作破解PDF加密文件
- 洛谷 P1856 [USACO5.5]矩形周长Picture
- 课堂练习4
- 十张图读懂 PHP、Python、 Ruby 三大语言的差异