搜索
首页web前端html教程Codeforces Round #277.5 (Div. 2)_html/css_WEB-ITnose

A. SwapSort

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.

Note that in this problem you do not have to minimize the number of swaps ? your task is to find any sequence that is no longer than n.

Input

The first line of the input contains integer n (1?≤?n?≤?3000) ? the number of array elements. The second line contains elements of array: a0,?a1,?...,?an?-?1 (?-?109?≤?ai?≤?109), where ai is the i-th element of the array. The elements are numerated from 0 to n?-?1 from left to right. Some integers may appear in the array more than once.

Output

In the first line print k (0?≤?k?≤?n) ? the number of swaps. Next k lines must contain the descriptions of the k swaps, one per line. Each swap should be printed as a pair of integers i, j (0?≤?i,?j?≤?n?-?1), representing the swap of elements ai and aj. You can print indices in the pairs in any order. The swaps are performed in the order they appear in the output, from the first to the last. It is allowed to print i?=?jand swap the same pair of elements multiple times.

If there are multiple answers, print any of them. It is guaranteed that at least one answer exists.

Sample test(s)

input

55 2 5 1 4

output

20 34 2

input

610 20 20 40 60 60

output

input

2101 100

output

1<p>0 1</p><p></p><p></p><pre name="code" class="n">#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[3010];int b[120];int vis[120];typedef pair<int> P;P m[3010];int main(){   #ifdef xxz    freopen("in.txt","r",stdin);    #endif // [xxz    int n;    cin>>n;    for(int i = 0; i >a[i];    int sum = 0,ans = 0;    int i,j;    for(i = 0; i  a[j])           {                x = a[j];                y = j;           }        }        if(y != i)        {            m[sum].first = i;            m[sum++].second = y;            swap(a[i],a[y]);            ans++;        }    }    cout<br><p></p>                      <p class="sycode">                          </p>
<p class="sycode">        </p>
<p class="sycode">         </p>
<p class="sycode">          </p>
<p class="sycode">           </p>
<p class="sycode">            </p>
<p class="sycode">             B. BerSU Ball            </p>            <p class="sycode">             </p>
<p class="sycode">              time limit per test             </p>1 second                        <p class="sycode">             </p>
<p class="sycode">              memory limit per test             </p>256 megabytes                        <p class="sycode">             </p>
<p class="sycode">              input             </p>standard input                        <p class="sycode">             </p>
<p class="sycode">              output             </p>standard output                                  <p class="sycode">            </p>
<p>The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves.</p>            <p>We know that several boy&girl pairs are going to be invited to the ball. However, the partners' dancing skill in each pair must differ by at most one.</p>            <p>For each boy, we know his dancing skills. Similarly, for each girl we know her dancing skills. Write a code that can determine the largest possible number of pairs that can be formed from n boys and m girls.</p>                      <p class="sycode">            </p>
<p class="sycode">             Input            </p>            <p>The first line contains an integer n (1?≤?n?≤?100) ? the number of boys. The second line contains sequence a1,?a2,?...,?an (1?≤?ai?≤?100), where ai is the i-th boy's dancing skill.</p>            <p>Similarly, the third line contains an integer m (1?≤?m?≤?100) ? the number of girls. The fourth line contains sequence b1,?b2,?...,?bm (1?≤?bj?≤?100), where bj is the j-th girl's dancing skill.</p>                      <p class="sycode">            </p>
<p class="sycode">             Output            </p>            <p>Print a single number ? the required maximum possible number of pairs.</p>                      <p class="sycode">            </p>
<p class="sycode">             Sample test(s)            </p>            <p class="sycode">             </p>
<p class="sycode">              </p>
<p class="sycode">               input              </p>              <pre style="代码" class="n">41 4 6 255 1 5 7 9

output

input

41 2 3 4410 11 12 13

output

input

51 1 1 1 131 2 3

output


#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[120];int b[120];int vis[120];int main(){   #ifdef xxz    freopen("in.txt","r",stdin);    #endif // [xxz    int n,m;    cin>>n;    for(int i = 0; i >a[i];    sort(a,a+n);    cin>>m;    for(int i = 0; i >b[i],vis[i] = 0;    sort(b,b+m);    int sum = 0;    int j;    for(int i =0; i <br>                      <p class="sycode">                          </p>
<p class="sycode">        C. Given Length and Sum of Digits...       </p>                          <p class="sycode">        </p>
<p class="sycode">         time limit per test        </p>1 second                                 <p class="sycode">        </p>
<p class="sycode">         memory limit per test        </p>256 megabytes                                 <p class="sycode">        </p>
<p class="sycode">         input        </p>standard input                                 <p class="sycode">        </p>
<p class="sycode">         output        </p>standard output                                                   <p class="sycode">                          </p>
<p>You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.</p>                                            <p class="sycode">                          </p>
<p class="sycode">        Input       </p>                          <p>The single line of the input contains a pair of integers m, s (1?≤?m?≤?100,?0?≤?s?≤?900) ? the length and the sum of the digits of the required numbers.</p>                                            <p class="sycode">                          </p>
<p class="sycode">        Output       </p>                          <p>In the output print the pair of the required non-negative integer numbers ? first the minimum possible number, then ? the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).</p>                                            <p class="sycode">                          </p>
<p class="sycode">        Sample test(s)       </p>                          <p class="sycode">        </p>
<p class="sycode">         </p>
<p class="sycode">          input         </p>         <pre style="代码" class="n">2 15

output

69 96

input

3 0

output

-1 -1
#include <iostream>#include <algorithm>#include <cstdio>using namespace std;bool can(int m, int s){    if(s >= 0 && 9*m >= s) return true;    else return false;}int main(){    int m,s;    cin>>m>>s;    if(!can(m,s))    {        cout= 10)        {            cout 0 || (j == 0 && i > 1) ) && can(m - i, sum - j))                   {                       minn += char('0' + j);                       sum -= j;                       break;                   }            }            sum = s;               for(int i = 1; i = 0; j--)            {                if(can(m - i, sum - j))                   {                       maxn += char('0' + j);                       sum -= j;                       break;                   }            }            cout<br><br><p></p></cstdio></algorithm></iostream>
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
了解HTML,CSS和JavaScript:初学者指南了解HTML,CSS和JavaScript:初学者指南Apr 12, 2025 am 12:02 AM

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

HTML的角色:构建Web内容HTML的角色:构建Web内容Apr 11, 2025 am 12:12 AM

HTML的作用是通过标签和属性定义网页的结构和内容。1.HTML通过到、等标签组织内容,使其易于阅读和理解。2.使用语义化标签如、等增强可访问性和SEO。3.优化HTML代码可以提高网页加载速度和用户体验。

HTML和代码:仔细观察术语HTML和代码:仔细观察术语Apr 10, 2025 am 09:28 AM

htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代码” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代码”代码“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract

HTML,CSS和JavaScript:Web开发人员的基本工具HTML,CSS和JavaScript:Web开发人员的基本工具Apr 09, 2025 am 12:12 AM

HTML、CSS和JavaScript是Web开发的三大支柱。1.HTML定义网页结构,使用标签如、等。2.CSS控制网页样式,使用选择器和属性如color、font-size等。3.JavaScript实现动态效果和交互,通过事件监听和DOM操作。

HTML,CSS和JavaScript的角色:核心职责HTML,CSS和JavaScript的角色:核心职责Apr 08, 2025 pm 07:05 PM

HTML定义网页结构,CSS负责样式和布局,JavaScript赋予动态交互。三者在网页开发中各司其职,共同构建丰富多彩的网站。

HTML容易为初学者学习吗?HTML容易为初学者学习吗?Apr 07, 2025 am 12:11 AM

HTML适合初学者学习,因为它简单易学且能快速看到成果。1)HTML的学习曲线平缓,易于上手。2)只需掌握基本标签即可开始创建网页。3)灵活性高,可与CSS和JavaScript结合使用。4)丰富的学习资源和现代工具支持学习过程。

HTML中起始标签的示例是什么?HTML中起始标签的示例是什么?Apr 06, 2025 am 12:04 AM

AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。

如何利用CSS的Flexbox布局实现菜单中虚线分割效果的居中对齐?如何利用CSS的Flexbox布局实现菜单中虚线分割效果的居中对齐?Apr 05, 2025 pm 01:24 PM

如何设计菜单中的虚线分割效果?在设计菜单时,菜名和价格的左右对齐通常不难实现,但中间的虚线或点如何...

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
4 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。