思路

贪心,找到将s至多交换一次所能得到的字典序最小的字符串,再与c比较。

实现:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int n; cin >> n;
while (n--)
{
string s, c;
cin >> s >> c;
if (s < c) { cout << s << endl; continue; }
string t = s;
sort(t.begin(), t.end());
int n = s.length();
bool flg = false;
for (int i = ; i < n; i++)
{
if (flg) break;
if (s[i] != t[i])
{
for (int j = n - ; j > i; j--)
{
if (s[j] == t[i])
{
swap(s[i], s[j]); flg = true; break;
}
}
}
}
if (s < c) cout << s << endl;
else cout << "---" << endl;
}
return ;
}

CF1281B Azamon Web Services的更多相关文章

  1. CF 1281B Azamon Web Services

    原题链接:http://codeforces.com/problemset/problem/1281/B 题目大意: 给你两个字符串 s 和 c ,最多经过一次变换,使s的字典序小于c,输出变换后的s ...

  2. .NET RESTful Web Services入门

    很早之前看到过RESTful Web Services,并未在意,也没找相关资料进行学习.今天偶尔有一机会,就找了点资料进行研究,发现RESTful真是“简约而不简单”.下面用示例来说明: 1 项目结 ...

  3. 分分钟带你玩转 Web Services

    当大型需求被数个公司分割开来,各公司系统相互交换数据的问题就会接踵而来. 毕竟是多家不同的公司的产品,研发开发语言.采用技术框架基本上是百花齐放. 怎样让自家系统提供的服务具有跨平台.跨语言.跨各种防 ...

  4. BizTalk发布WS-Security的web services

    最近做个项目,biztalk跟OTM(Oracle Transportation Management)系统做对接,双方通过web services通讯,这部分是BizTalk发布WS-Securit ...

  5. BizTalk调用WS-Security的web services

    最近做个项目,biztalk跟OTM(Oracle Transportation Management)系统做对接,双方通过web services通讯,这部分是BizTalk调用OTM的web se ...

  6. 【整理】动态加载Web Services

    WebClient client = new WebClient(); String url = "http://localhost/MESAPIWebService/MESAPI.asmx ...

  7. RESTful Web Services初探

    RESTful Web Services初探 作者:杜刚 近几年,RESTful Web Services渐渐开始流行,大量用于解决异构系统间的通信问题.很多网站和应用提供的API,都是基于RESTf ...

  8. asp.net Ajax和web services

    新建一个web服务 using System; using System.Collections.Generic; using System.Linq; using System.Web; using ...

  9. 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 ...

随机推荐

  1. learning java Calendar类

    //Calendar.MONTH ,这是一个特殊于日历的值. //在格里高利历和罗马儒略历中一年中的第一个月是 JANUARY,它为 0:最后一个月取决于一年中的月份数. // //所以这个值的初始值 ...

  2. mock模拟后台数据

    import Mock from 'mockjs' const Random = Mock.Random // 获取random对象,随机生成各种数据,具体请翻阅文档 const domain = ' ...

  3. Bzoj 1010: [HNOI2008]玩具装箱toy(斜率优化)

    1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec Memory Limit: 162 MB Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定 ...

  4. linux安装sox,踩过坑的方法

    参考文章 : https://blog.csdn.net/e_zhiwen/article/details/80037476 重新在源码中 执行一遍 ./configure --prefix=$HOM ...

  5. Matlab中的变量名

    在Matlab中使用save和load命令时,可能会出现变量名出错的问题. 如: save('A1.mat', 'A1'); load('A1.mat', 'A1'); 如果程序中还有名为a1的变量名 ...

  6. SyntaxError: Non-ASCII character 'æ' in file csdn.py on line 7, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

    错误信息: SyntaxError: Non-ASCII character , but no encoding declared; see http://python.org/dev/peps/pe ...

  7. python操作toml文件

    # -*- coding: utf-8 -*- # @Time : 2019-11-18 09:31 # @Author : cxa # @File : toml_demo.py # @Softwar ...

  8. Oracle语法 及 SQL题目(一)

    目录 课例复制 SQL题目一 SQL题目二 SQL题目三 笔记 课例复制 OCM 全称:Oracle Certified Master 认证大师 含义:Oracle 原厂推出的数据库方向最高级别认证 ...

  9. php手记之07-tp5 cookie与session

    ThinkPHP采用 01-think\facade\Cookie类提供Cookie支持. 02-think\Cookie 配置文件位于 config/cookie.php中,一般会配置一个超时时间. ...

  10. PostgreSQL定时自动备份

    PostgreSQL定时自动备份 简介 PostgreSQL数据库中未提供数据库的定时备份功能,所以需要结合备份和定时job功能来共同实现. 这里我选取了2种定时job方式,crontab是Linux ...