• ACM儿童节热身训练


    今天下午跟同学水了一场比赛,这次打的是真的不怎么样啊,一开始我迟到了半个小时,在路上看题,后来到了最后一个多小时,队友心态稳不住了,本来能过五个的题目最后只AC了三个,唉。。。
    记得看题的时候先看了前三个,我到的时候队友在做A题,我到了问怎么样,我说不行咱先做C题,他说我先试试,这时候B题的构思已经完成了,然后我们按B-C-A的顺序依次提交去做了别的题目,到最后一个多小时我们提交了五个,但是有的题目排了两个小时队就是排不上,不是提交失败就是排队中,手机没电了,热点也没法用了,心态也控制不了了,回到宿舍A题CE了,H题超时,A题是输入输出上应当使用VC的写法,H题使用二分解决就好,但是这个时候已经没有心思去改了。
    以后一定要稳住,千万不能这样了。另外还是做的太少了,缺乏经验,要加强练习啊,不到最后一刻千万不能放弃啊。。。
    其实做任何事都是这样,要坚持才行啊,不能因为某些客观因素就放弃啊。
    下面写一下今天的少的可怜的那几道题:
    In the beginning of the new year Keivan decided to reverse his name. He doesn’t like palindromes, so he changed Naviek to Navick.

    He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either ‘a’, ‘b’ or ‘c’, with no palindromes of length 3 appearing in the string as a substring. For example, the strings “abc” and “abca” suit him, while the string “aba” doesn’t. He also want the number of letters ‘c’ in his string to be as little as possible.

    Input
    The first line contains single integer n (1 ≤ n ≤ 2·105) — the length of the string.

    Output
    Print the string that satisfies all the constraints.

    If there are multiple answers, print any of them.

    Examples
    Input
    2
    Output
    aa
    Input
    3
    Output
    bba
    

    Note
    A palindrome is a sequence of characters which reads the same backward and forward.

    #include<iostream>
    #include<cstring>
    #include<string>
    using namespace std;
    int main()
    {
    	int n, i;
    	while (cin >> n)
    	{
    		for (i = 0; i <= n - 4; i += 4)
    		{
    			cout << "aabb";
    		}
    		int x = n - i;
    		if (x == 1)
    			cout << "a";
    		else if (x == 2)
    			cout << "aa";
    		else if (x == 3)
    			cout << "aab";
    		cout << endl;
    	}
    }
    

    A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.

    There are n schools numerated from 1 to n. One can travel between each pair of them, to do so, he needs to buy a ticket. The ticker between schools i and j costs and can be used multiple times. Help Sajjad to find the minimum cost he needs to pay for tickets to visit all schools. He can start and finish in any school.

    Input
    The first line contains a single integer n (1 ≤ n ≤ 105) — the number of schools.

    Output
    Print single integer: the minimum cost of tickets needed to visit all schools.

    Examples
    Input
    2
    Output
    0
    Input
    10
    Output
    4
    

    Note
    In the first example we can buy a ticket between the schools that costs .

    #include<iostream>
    #include<cstdio>
    #include<string>
    #include<vector>
    #include<set>
    #include<cmath>
    #include<algorithm>
    //int cost=0,tmp=0,maxx=0;
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        n=n-1;
        cout<<n/2;
    }
    

    Is it rated?

    Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.

    Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.

    It’s known that if at least one participant’s rating has changed, then the round was rated for sure.

    It’s also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant’s rating has changed.

    In this problem, you should not make any other assumptions about the rating system.

    Determine if the current round is rated, unrated, or it’s impossible to determine whether it is rated of not.

    Input
    The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.

    Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.

    Output
    If the round is rated for sure, print “rated”. If the round is unrated for sure, print “unrated”. If it’s impossible to determine whether the round is rated or not, print “maybe”.

    Examples
    Input
    6
    3060 3060
    2194 2194
    2876 2903
    2624 2624
    3007 2991
    2884 2884
    Output
    rated
    Input
    4
    1500 1500
    1300 1300
    1200 1200
    1400 1400
    Output
    unrated
    Input
    5
    3123 3123
    2777 2777
    2246 2246
    2246 2246
    1699 1699
    Output
    maybe
    

    Note
    In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.

    In the second example, no one’s rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone’s rating would’ve changed for sure.

    In the third example, no one’s rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it’s impossible to determine whether the round is rated or not.

    #include<iostream>
    #include<cstdio>
    #include<string>
    #include<vector>
    #include<set>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    int main()
    {
        int a[10001],b[10001];
        int n,count1=0,count2=0;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
            if(a[i]==b[i]) count1++;
        }
        if(count1!=n) {cout<<"rated";return 0;}
        for(int i=0;i<n-1;i++)
        {
            if(a[i]>=a[i+1]) count2++;
        }
        if(count2==n-1) {cout<<"maybe";return 0;}
        cout<<"unrated";
    }
    
  • 相关阅读:
    CentOS 5.5 系统安全配置
    从PHP5.2.x迁移到PHP5.3.x
    快要放假了!但为什么现在感到特别的累呢?!
    C#、Oracle、Sql server中拼音查询的函数
    C#实现Word中表格信息读取
    用 win2003 架设共享服务器[3]
    用 win2003 架设共享服务器[2]
    用 win2003 架设共享服务器[1]
    c#操作word表格
    Visual Studio 2008(VS2008)升级正式版
  • 原文地址:https://www.cnblogs.com/study-hard-forever/p/12129999.html
Copyright © 2020-2023  润新知