140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第三部分)

Earthstone Keeper


Time Limit: 4 Seconds       Memory Limit: 65536 KB

Earthstone Keeper is a famous roguelike game created by Lizard Entertainment. In this game, an adventurer will explore in a single layer dungeon of N × M size.

The adventurer starts at the room (SR, SC) and he wants to go to the room located at (TR, TC) since there hides a big treasure box full of gold and diamonds! However, exploration is not always an easy job. There are many traps and monsters in the dungeon. To be specific, there are 4 types of rooms:

 

  1. Common. The room is safe.
  2. Obstacles. The room is full of obstacles that the adventurer cannot enter it.
  3. Trap. The room has been set up with a trap. The trap will be triggered when the adventurer enters the room. When the adventurer leaves, the trap will reset so it can be triggered next time.
  4. Monster. There is a monster standing in it. If the adventurer walks into a monster room or any room adjacent to a monster room, the monster will immediately rush up to the adventurer and fight with him. Once the monster is killed, the adventurer can continue his exploration. Of course, the monster will not revive.

 

Two rooms are adjacent if and only if they share an edge. The adventurer can take 1 minute to go from a room to an adjacent room. Traps or monsters are always dangerous. More precisely, there is a fatality value for each trap and monster. Although our adventurer is strong and swift, battling with a deadly monster or dodging a rolling stone trap are not wise options.

140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第三部分)

The dungeon has been sealed by its owner with a powerful magic so the adventurer can not escape to outside until he found the treasure. By the way, being afraid of monsters battling with each other, the dungeon owner will not set any two monster rooms adjacent to each other. The room (SR, SC) and (TR, TC) are always common rooms and will not be adjacent to any monster room.

The adventurer want choose a best path to the treasure. The total fatality value of all monsters he killed and all traps he triggered should be as low as possible (If a trap was triggered multiple times, the fatality should also count multiple times). Among all safest paths, he want to choose the shortest path lead to the treasure room.

Please write program to help the adventurer find out the best path to the treasure.

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first line contains two integers N and M (1 <= NM <= 500). The second line contains 4 integers SRSCTRTC (1 <= SRTR <= N and 1 <= SCTC <= M).

For the next N lines, each line contains M characters indicating the map of dungeon. Each type of room is marked as:

 

  1. Common: "."
  2. Obstacles: "#"
  3. Trap: from "a" to "z"
  4. Monster: from "A" to "Z"

 

The fatality value of trap "a" and monster "A" is 1. The fatality value of trap "b" and monster "B" is 2, and so on. Therefore, the most dangerous trap "z" or monster "Z" has its fatality value equal to 26.

Output

For each test case, output the total fatality value and the time cost (in minutes) of the best path, separated by a space. It is guaranteed that there always exists at least one path from (SR, SC) to (TR, TC).

Sample Input

1

3 5

1 1 3 5

..b..

.#C#.

..a..

Sample Output

4 6


没看题...

Convert QWERTY to Dvorak


Time Limit: 2 Seconds       Memory Limit: 65536 KB

Edward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard with a broken Caps Lock key, so Edward never presses the broken Caps Lock key. Luckily, all the other keys on the QWERTY keyboard work well. Every day, he has a lot of documents to type. Thus he needs a converter to translate QWERTY into Dvorak. Can you help him?

The QWERTY Layout and the Dvorak Layout are in the following:

Qwerty Layout
The QWERTY Layout

Dvorak Layout
The Dvorak Layout

Input

A QWERTY document Edward typed. The document has no more than 100 kibibytes. And there are no invalid characters in the document.

Output

The Dvorak document.

Sample Input

Jgw Gqm Andpw a H.soav Patsfk f;doe

Nfk Gq.d slpt a X,dokt vdtnsaohe

Kjd yspps,glu pgld; aod yso kd;kgluZ

1234567890

`~!@#$%^&*()}"']_+-=ZQqWEwe{[\|

ANIHDYf.,bt/

ABCDEFuvwxyz

Sample Output

Hi, I'm Abel, a Dvorak Layout user.

But I've only a Qwerty keyboard.

The following lines are for testing:

1234567890

`~!@#$%^&*()+_-={}[]:"'<>,.?/\|

ABCDEFuvwxyz

AXJE>Ugk,qf;


题意:把第一个键盘的数输入,输出是按第二个键盘;

思路:打表...

转载请注明出处:
寻找&星空の孩子


#include <iostream>

#include <stdio.h>

#include <string.h>

#include <stack>

#include <queue>

#include <map>

#include <set>

#include <vector>

#include <math.h>

#include <algorithm>

using namespace std;

#define ls 2*i

#define rs 2*i+1

#define up(i,x,y) for(i=x;i<=y;i++)

#define down(i,x,y) for(i=x;i>=y;i--)

#define mem(a,x) memset(a,x,sizeof(a))

#define w(a) while(a)

#define LL long long

const double pi = acos(-1.0);

#define Len 20005

#define mod 19999997

const int INF = 0x3f3f3f3f;



char s1[]= {"-=_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?"};

char s2[]= {"[]{}',.pyfgcrl/=\"<>PYFGCRL?+aoeuidhtns-AOEUIDHTNS_;qjkxbmwvz:QJKXBMWVZ"};

char c;



char print(char c)

{

    for(int i=0; s1[i]; i++)

        if(s1[i]==c)

            return s2[i];

    return c;

}

int main()

{

    w(~scanf("%c",&c))

    {

        printf("%c",print(c));

    }



    return 0;

}
 
  

 

 
  
Capture the Flag
 
  
 
  
Time Limit: 2 Seconds       Memory Limit: 65536 KB       Special Judge
 
  
 
  

In computer security, Capture the Flag (CTF) is a computer security competition. CTF contests are usually designed to serve as an educational exercise to give participants experience in securing a machine, as well as conducting and reacting to the sort of attacks found in the real world. Reverse-engineering, network sniffing, protocol analysis, system administration, programming, and cryptanalysis are all skills which have been required by prior CTF contests at DEF CON. There are two main styles of capture the flag competitions: attack/defense and jeopardy.

 
  

In an attack/defense style competition, each team is given a machine (or a small network) to defend on an isolated network. Teams are scored on both their success in defending their assigned machine and on their success in attacking other team's machines. Depending on the nature of the particular CTF game, teams may either be attempting to take an opponent's flag from their machine or teams may be attempting to plant their own flag on their opponent's machine.

 
  

Recently, an attack/defense style competition called MCTF held by Marjar University is coming, and there are N teams which participate in the competition. In the beginning, each team has S points as initial score; during the competition, there are some checkpoints which will renew scores for all teams. The rules of the competition are as follows:

 
  
  • If a team has been attacked for a service P, they will lose N - 1 points. The lost points will be split equally and be added to the team(s) which attacks successfully. For example, there are 4 teams and Team A has been attacked by Team B and Team C, so Team A will lose 3 points, while Team B and Team C each will get 1.5 points.
  • If a team cannot maintain their service well, they will lose N - 1 points, which will be split equally too and be added to the team(s) which maintains the service well.
 
  

The score will be calculated at the checkpoints and then all attacks will be re-calculated. Edward is the organizer of the competition and he needs to write a program to display the scoreboard so the teams can see their scores instantly. But he doesn't know how to write. Please help him!

 
  

Input

 
  

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

 
  

The first line contains four integers N (2 <= N <= 100) - the number of teams, Q - the number of services (1 <= Q <= 10), S - the initial points (0 <= S <= 100000) and C - the number of checkpoints (1 <= C <= 100).

 
  

For each checkpoint, there are several parts:

 
  
  • The first line contains an integer A - the number of the successful attacks. Then A lines follow and each line contains a message:
    [The No. of the attacker] [The No. of the defender] [The No. of the service]
    For example, "1 2 3" means the 1st team attacks the 2nd team in service 3 successfully. The No. of teams and services are indexed from 1. You should notice that duplicate messages are invalid because of the rules. Just ignore them.
  • Then there are Q lines and each line contains N integers. The jth number of the ith line indicating the jth team's maintaining status of the ith service, where 1 means well and 0 means not well.
  • Finally there is an integer U (0 <= U <= 100), which describing the number of the queries. The following line contains U integers, which means Edward wants to know the score and the ranking of these teams.
 
  

 

 
  

Output

 
  

For each query L, output the score and the ranking of the Lth team. The relative error or absolute error of the score should be less than 10-5. The team with higher score gets higher rank; the teams with the same scores should have the same rank. It is guaranteed that the scores of any two teams are either the same or with a difference greater than 10-5.

 
  

Sample Input

 
  
1

4 2 2500 5

0

1 1 1 1

1 1 1 1

4

1 2 3 4

2

1 2 1

3 2 1

1 1 1 1

1 1 1 1

4

1 2 3 4

1

1 2 2

1 1 1 1

1 1 1 0

4

1 2 3 4

0

0 0 0 0

0 0 0 0

4

1 2 3 4

0

1 1 1 1

1 1 1 1

2

1 4

 
  

Sample Output

 
  
2500.00000000 1

2500.00000000 1

2500.00000000 1

2500.00000000 1

2501.50000000 1

2497.00000000 4

2501.50000000 1

2500.00000000 3

2505.50000000 1

2495.00000000 4

2502.50000000 2

2497.00000000 3

2499.50000000 1

2489.00000000 4

2496.50000000 2

2491.00000000 3

2499.50000000 1

2491.00000000 3

 
  

Hint

 
  

For C++ users, kindly use scanf to avoid TLE for huge inputs.

 

 

队友默默A的:http://blog.csdn.net/libin56842/article/details/45272717



Demacia of the Ancients
 
  
 
  
Time Limit: 2 Seconds       Memory Limit: 65536 KB
 
  
 
  

There is a popular multiplayer online battle arena game called Demacia of the Ancients. There are lots of professional teams playing this game. A team will be approved as Level K if there are exact K team members whose match making ranking (MMR) is strictly greater than 6000.

 
  

You are given a list of teams. Please calculate the level of each team.

 
  

Input

 
  

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

 
  

The first line contains an integer N (1 <= N <= 10) indicating the number of team members.

 
  

The second line contains N integers representing the MMR of each team member. All MMRs are non-negative integers less than or equal to 9999.

 
  

Output

 
  

For each test case, output the level of the given team.

 
  

Sample Input

 
  
3

5

7986 6984 6645 6200 6150

5

7401 7377 6900 6000 4300

3

800 600 200

 
  

Sample Output

 
  
5

3

0
 
#include <iostream>

#include <stdio.h>

#include <string.h>

#include <stack>

#include <queue>

#include <map>

#include <set>

#include <vector>

#include <math.h>

#include <algorithm>

using namespace std;

#define ls 2*i

#define rs 2*i+1

#define up(i,x,y) for(i=x;i<=y;i++)

#define down(i,x,y) for(i=x;i>=y;i--)

#define mem(a,x) memset(a,x,sizeof(a))

#define w(a) while(a)

#define LL long long

const double pi = acos(-1.0);

#define Len 20005

#define mod 19999997

const int INF = 0x3f3f3f3f;



int n,t,a,cnt,i;



int main()

{

    scanf("%d",&t);

    w(t--)

    {

        scanf("%d",&n);

        cnt = 0;

        w(n--)

        {

            scanf("%d",&a);

            if(a>6000)

            cnt++;

        }

        printf("%d\n",cnt);

    }



    return 0;

}
 
  

 



你可能感兴趣的:(programming)