CF 1281B Azamon Web Services
原题链接:http://codeforces.com/problemset/problem/1281/B
题目大意: 给你两个字符串 s 和 c ,最多经过一次变换,使s的字典序小于c,输出变换后的s ,如果不成立输出---
思路: 直接对s进行遍历,找到经过一次变换后字典序最小的s。 要找字典序最小的s,变换时就要将位置靠后的,字典序小的换到前面。
ABACA AABBC
代码
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#define ll long long
#define pi 3.1415927
#define inf 0x3f3f3f3f
using namespace std;
string s,c,kk;
int main ()
{
int n,m,i,t,sum,j,k,f=;
cin>>n;
while(n--)
{
cin>>s>>c;
k=s.length();
f=;
for(i=;i<k-;++i){
int jj=i;
for(t=k-;t>=jj+;--t)
{
if(s[i]>s[t])
i=t,j=t,f=; ///从后往前遍历,如果当前字符小的话就记录下来,
}
if(f){
swap(s[jj],s[j]); ///jj是记录的第一层循环的 i ,j是找到的靠后的最小的字符
break;
}
}
//cout<<s<<endl;
if(s<c)
cout<<s<<endl;
else
cout<<"---"<<endl;
}
return ;
}
CF 1281B Azamon Web Services的更多相关文章
- CF1281B Azamon Web Services
思路: 贪心,找到将s至多交换一次所能得到的字典序最小的字符串,再与c比较. 实现: #include <bits/stdc++.h> using namespace std; int m ...
- .NET RESTful Web Services入门
很早之前看到过RESTful Web Services,并未在意,也没找相关资料进行学习.今天偶尔有一机会,就找了点资料进行研究,发现RESTful真是“简约而不简单”.下面用示例来说明: 1 项目结 ...
- 分分钟带你玩转 Web Services
当大型需求被数个公司分割开来,各公司系统相互交换数据的问题就会接踵而来. 毕竟是多家不同的公司的产品,研发开发语言.采用技术框架基本上是百花齐放. 怎样让自家系统提供的服务具有跨平台.跨语言.跨各种防 ...
- BizTalk发布WS-Security的web services
最近做个项目,biztalk跟OTM(Oracle Transportation Management)系统做对接,双方通过web services通讯,这部分是BizTalk发布WS-Securit ...
- BizTalk调用WS-Security的web services
最近做个项目,biztalk跟OTM(Oracle Transportation Management)系统做对接,双方通过web services通讯,这部分是BizTalk调用OTM的web se ...
- 【整理】动态加载Web Services
WebClient client = new WebClient(); String url = "http://localhost/MESAPIWebService/MESAPI.asmx ...
- RESTful Web Services初探
RESTful Web Services初探 作者:杜刚 近几年,RESTful Web Services渐渐开始流行,大量用于解决异构系统间的通信问题.很多网站和应用提供的API,都是基于RESTf ...
- asp.net Ajax和web services
新建一个web服务 using System; using System.Collections.Generic; using System.Linq; using System.Web; using ...
- SpringSide 部署showcase项目出现 JAX-RS (REST Web Services) 2.0 can not be installed错误!
maven+springmvc错误 JAX-RS (REST Web Services) 2.0 can not be installed 项目problem提示错误 JAX-RS (REST Web ...
随机推荐
- Flask-session用法
概念 flask-session是flask框架的session组件,由于原来flask内置session使用签名cookie保存,该组件则将支持session保存到多个地方,如: * redis:保 ...
- Photoshop基础照片美化
自从有了“ps”以后,很多事情变成了可能,你可以出现在任何你想在的地方.而最基本的美化照片的功能,我想是很多同学学习PS的初衷.当你掌握了这门技术,很多人会对你刮目相看!今天小编就和大家分享一下ps的 ...
- logback日志文件的使用
1.引入Jar包,Maven pom.xml <!-- Logging with SLF4J & LogBack --> <dependency> <groupI ...
- MySQL 05章_模糊查询和聚合函数
在之前的查询都需要对查询的关机中进行“精确”.“完整”完整的输入才能查询相应的结果, 但在实际开发过程中,通常需要考虑用户可能不知道“精确”.“完整”的关键字, 那么就需要提供一种不太严格的查询方式, ...
- 【学术篇】SDOI2010 古代猪文
这里可能包含传送门 又双叒叕数论大杂烩... 定理什么我都不会证 题目很长很啰嗦 但是题意很显然... 化完式子之后就是这么个东东:\(G^{\sum_{k|n}C_k^{\frac{n}{k}}}\ ...
- 06.Mybatis关联查询
1.一对一关联查询 需求:查询出每条orders记录和其关联的user信息 在orders实体类中添加属性与set.get方法 /** * 测试1对1关联查询 */ private User user ...
- range和arange
a = np.arange(12) print(a, type(a)) b = range(10) print(b, type(b)) li = list(b) print(li) 拓展: 两个参数: ...
- cordova 插件发布到 npm
cordova 插件发布到 npm Cordova插件开发(3)- 将Cordova插件发布到npm could not find an installed version of gradle eit ...
- 学习修复Laravel The only supported ciphers are AES-128-CBC and AES-256-CBC
The only supported ciphers are AES-128-CBC and AES-256-CBC 在项目中,删除了 .env的APP_KEY的值,再运行 php artisan k ...
- What is the difference between HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR
What is the difference between HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR? it is impossible to say. Dif ...