zoukankan      html  css  js  c++  java
  • Coder-Strike 2014

    A. Password Check
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a message is displayed. Today your task is to implement such an automatic check.

    Web-developers of the company Q assume that a password is complex enough, if it meets all of the following conditions:

    • the password length is at least 5 characters;
    • the password contains at least one large English letter;
    • the password contains at least one small English letter;
    • the password contains at least one digit.

    You are given a password. Please implement the automatic check of its complexity for company Q.

    Input

    The first line contains a non-empty sequence of characters (at most 100 characters). Each character is either a large English letter, or a small English letter, or a digit, or one of characters: "!", "?", ".", ",", "_".

    Output

    If the password is complex enough, print message "Correct" (without the quotes), otherwise print message "Too weak" (without the quotes).

    Sample test(s)
    input
    abacaba
    output
    Too weak
    input
    X12345
    output
    Too weak
    input
    CONTEST_is_STARTED!!11
    output
    Correct
    ANS:一条条的去满足条件
    #include<iostream>
    #include<cstring>
    #include<stdio.h>
    using namespace std;
    int main()
    {
        char a[105];
       int i,j,k,l,s,m,n;
        scanf("%s",&a);
        l=strlen(a);
        bool b=false,b1=false,b2=false;
        if (l<5)
         {cout<<"Too weak"<<endl;
         return 0;}
        for (i=0;i<l;i++)
         {j=int(a[i]);
         if (j>=65&&j<=90)
          b=true;
        if (j>=97&&j<=122)
         b1=true;
        if (j>=48&&j<=57)
         b2=true;
        }
    if (b==true&&b1==true&&b2==true)
     cout<<"Correct";
     else cout<<"Too weak";
    }
    
    
    
     
    B. Multi-core Processor
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.

    At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to the cell). After receiving the command, the core executes it immediately. Sometimes it happens that at one cycle, multiple cores try to write the information into a single cell. Unfortunately, the developers did not foresee the possibility of resolving conflicts between cores, so in this case there is a deadlock: all these cores and the corresponding memory cell are locked forever. Each of the locked cores ignores all further commands, and no core in the future will be able to record an information into the locked cell. If any of the cores tries to write an information into some locked cell, it is immediately locked.

    The development team wants to explore the deadlock situation. Therefore, they need a program that will simulate the processor for a given set of instructions for each core within m cycles . You're lucky, this interesting work is entrusted to you. According to the instructions, during the m cycles define for each core the number of the cycle, during which it will become locked. It is believed that initially all cores and all memory cells are not locked.

    Input

    The first line contains three integers nmk (1 ≤ n, m, k ≤ 100). Then follow n lines describing instructions. The i-th line contains mintegers: xi1, xi2, ..., xim (0 ≤ xij ≤ k), where xij is the instruction that must be executed by the i-th core at the j-th cycle. If xij equals 0, then the corresponding instruction is «do nothing». But if xij is a number from 1 to k, then the corresponding instruction is «write information to the memory cell number xij».

    We assume that the cores are numbered from 1 to n, the work cycles are numbered from 1 to m and the memory cells are numbered from 1 to k.

    Output

    Print n lines. In the i-th line print integer ti. This number should be equal to 0 if the i-th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.

    Sample test(s)
    input
    4 3 5
    1 0 0
    1 0 2
    2 3 1
    3 2 0
    output
    1
    1
    3
    0
    input
    3 2 2
    1 2
    1 2
    2 2
    output
    1
    1
    0
    input
    1 1 1
    0
    output
    0
    ANS:设置数列,去掉不合理的
     1 void imp() {
     2     printf("Too weak");
     3     exit(0);
     4 }
     5 
     6 char st[100000];
     7 int const MAX_N = 400;
     8 int xx[500][500],mem_blocked[500],blocked[500],cur_cnt[500],ans[500];
     9 
    10 int main() {
    11     //freopen("input.txt","r",stdin);
    12     //freopen("output.txt","w",stdout);
    13 
    14     int n,m,k;
    15     scanf("%d%d%d",&n,&m,&k);
    16     for (int i=1; i<=n; i++)
    17         for (int j=1; j<=m; j++)
    18             scanf("%d",&xx[i][j]);
    19 
    20     for (int j=1; j<=m; j++) {
    21         for (int i=0; i<MAX_N; i++)
    22             cur_cnt[i] = 0;
    23         for (int i=1; i<=n; i++)
    24             if (!blocked[i] && xx[i][j]!=0) {
    25                 if (mem_blocked[xx[i][j]]) {
    26                     blocked[i] = 1;
    27                     ans[i] = j;
    28                 }
    29                 else cur_cnt[xx[i][j]]++;
    30             }
    31         for (int i=1; i<=n; i++)
    32             if (!blocked[i] && xx[i][j]!=0)
    33                 if (cur_cnt[xx[i][j]] >= 2) {
    34                     blocked[i] = 1;
    35                     ans[i] = j;
    36                     mem_blocked[xx[i][j]] = 1;
    37                 }
    38     }
    39 
    40     for (int i=1; i<=n; i++)
    41         cout<<ans[i]<<"
    ";
    42 
    43     return 0;
    44 }
    
    
    C. Kicker
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output
    
    

    Kicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of each team controls the goalkeeper and the full-backs (plays defence), the other player controls the half-backs and forwards (plays attack).

    Two teams of company Q decided to battle each other. Let's enumerate players from both teams by integers from 1 to 4. The first and second player play in the first team, the third and the fourth one play in the second team. For each of the four players we know their game skills in defence and attack. The defence skill of the i-th player is ai, the attack skill is bi.

    Before the game, the teams determine how they will play. First the players of the first team decide who will play in the attack, and who will play in the defence. Then the second team players do the same, based on the choice of their opponents.

    We will define a team's defence as the defence skill of player of the team who plays defence. Similarly, a team's attack is the attack skill of the player of the team who plays attack. We assume that one team is guaranteed to beat the other one, if its defence is strictly greater than the opponent's attack and its attack is strictly greater than the opponent's defence.

    The teams of company Q know each other's strengths and therefore arrange their teams optimally. Identify the team that is guaranteed to win (if both teams act optimally) or tell that there is no such team.

    
    
    Input

    The input contain the players' description in four lines. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 100)— the defence and the attack skill of the i-th player, correspondingly.

    
    
    Output

    If the first team can win, print phrase "Team 1" (without the quotes), if the second team can win, print phrase "Team 2" (without the quotes). If no of the teams can definitely win, print "Draw" (without the quotes).

    
    
    Sample test(s)
    input
    1 100
    100 1
    99 99
    99 99
    output
    Team 1
    input
    1 1
    2 2
    3 3
    2 2
    output
    Team 2
    input
    3 3
    2 2
    1 1
    2 2
    output
    Draw
    
    
    Note

    Let consider the first test sample. The first team can definitely win if it will choose the following arrangement: the first player plays attack, the second player plays defence.

    Consider the second sample. The order of the choosing roles for players makes sense in this sample. As the members of the first team choose first, the members of the second team can beat them (because they know the exact defence value and attack value of the first team).

    ANS:有点乱,要比较清楚
     1 #include<iostream>
     2 #include<stdio.h>
     3 using namespace std;
     4 int main()
     5 {
     6     int a[5],b[5],i,j,k,l,s,m,n,s1,l1;
     7     for (i=1;i<=4;i++)
     8     scanf("%d%d",&a[i],&b[i]);
     9     s=0;
    10     l=0;
    11     if (b[3]>a[1]&&a[4]>b[2])
    12      s++;
    13     if (b[4]>a[1]&&a[3]>b[2])
    14      s++;
    15      if (a[1]>b[3]&&b[2]>a[4])
    16       l++;
    17      if (a[1]>b[4]&&b[2]>a[3])
    18       l++;
    19     if (l==2)
    20      {cout<<"Team 1";
    21      return 0;
    22     }
    23     s1=l1=0;
    24     if (b[3]>a[2]&&a[4]>b[1])
    25      s1++;
    26     if (b[4]>a[2]&&a[3]>b[1])
    27      s1++;
    28      if (a[2]>b[3]&&b[1]>a[4])
    29       l1++;
    30      if (a[2]>b[4]&&b[1]>a[3])
    31       l1++;
    32     if (l1==2)
    33      {cout<<"Team 1";
    34      return 0;
    35     }
    36     if (s>0&&s1>0)
    37      {cout<<"Team 2";
    38      return 0;
    39     }
    40     cout<<"Draw";
    41 }
    
    
    
     
    
    
  • 相关阅读:
    Redis入门指南
    大公司都有哪些开源项目~~~阿里,百度,腾讯,360,新浪,网易,小米等
    01 背包问题和完全背包
    糖果(动规)
    数的划分(动规)
    鸣人的影分身(动规)
    股票买卖(动规)
    大盗阿福(动规)
    公共子序列(动规)
    滑雪(动规)
  • 原文地址:https://www.cnblogs.com/min1024/p/3695347.html
Copyright © 2011-2022 走看看