2013第一次组队训练赛

 

 Spell checker

Time Limit : 5000/2000ms (Java/Other)   Memory Limit : 65535/65535K (Java/Other)
Total Submission(s) : 11   Accepted Submission(s) : 2
Font: Times New Roman | Verdana | Georgia
Font Size: ← →

Problem Description

You are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms, for a new spell checking program,.
If the word is absent in the dictionary then it can be replaced by correct words (from the dictionary) that can be obtained by one of the following operations:
deleting of one letter from the word;
replacing of one letter in the word with an arbitrary letter;
inserting of one arbitrary letter into the word.
Your task is to write the program that will find all possible replacements from the dictionary for every given word.

Input

The first part of the input file contains all words from the dictionary. Each word occupies its own line. This part is finished by the single character '#' on a separate line. All words are different. There will be at most 10000 words in the dictionary.
The next part of the file contains all words that are to be checked. Each word occupies its own line. This part is also finished by the single character '#' on a separate line. There will be at most 50 words that are to be checked.
All words in the input file (words from the dictionary and words to be checked) consist only of small alphabetic characters and each one contains 15 characters at most.

Output

Write to the output file exactly one line for every checked word in the order of their appearance in the second part of the input file. If the word is correct (i.e. it exists in the dictionary) write the message: " is correct". If the word is not correct then write this word first, then write the character ':' (colon), and after a single space write all its possible replacements, separated by spaces. The replacements should be written in the order of their appearance in the dictionary (in the first part of the input file). If there are no replacements for this word then the line feed should immediately follow the colon(no space).

Sample Input

i
is
has
have
be
my
more
contest
me
too
if
award
#
me
aware
m
contest
hav
oo
or
i
fi
mre
#

Sample Output

me is correct
aware: award
m: i my me
contest is correct
hav: has have
oo: too
or: 
i is correct
fi: i
mre: more me

Author

hpustudent

 

 

 

棋盘问题

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)

Total Submission(s) : 24   Accepted Submission(s) : 5
Font: Times New Roman | Verdana | Georgia
Font Size: ← →

Problem Description

在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。

Input

输入含有多组测试数据。
每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n
当为-1 -1时表示输入结束。
随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示棋盘区域, . 表示空白区域(数据保证不出现多余的空白行或者空白列)。

Output

对于每一组数据,给出一行输出,输出摆放的方案数目C (数据保证C<2^31)

Sample Input

2 1
#.
.#
4 4
...#
..#.
.#..
#...
-1 -1

Sample Output

2
1

Author

hpustudent

 

 

 

Truck History 

Time Limit : 5000/2000ms (Java/Other)   Memory Limit : 65535/65535K (Java/Other)

Total Submission(s) : 18   Accepted Submission(s) : 3
Font: Times New Roman | Verdana | Georgia
Font Size: ← →

Problem Description

A company uses trucks of different types. The company has its own code describing each type of a truck. The code is simply a string of exactly seven lowercase letters (each letter on each position has a very special meaning but that is unimportant for this task). At the beginning of company's history, just a single truck type was used but later other types were derived from it, then from the new types another types were derived, and so on.

One thing historians tried to find out is so called derivation plan -- i.e. how the truck types were derived. They defined the distance of truck types as the number of positions with different letters in truck type codes. They also assumed that each truck type was derived from exactly one other truck type (except for the first truck type which was not derived from any other type). The quality of a derivation plan was then defined as
1/Σ(to,td)d(to,td)

where the sum goes over all pairs of types in the derivation plan such that to is the original type and td the type derived from it and d(to,td) is the distance of the types.
Since historians failed, you are to write a program to help them. Given the codes of truck types, your program should find the highest possible quality of a derivation plan.

Input

The input consists of several test cases. Each test case begins with a line containing the number of truck types, N, 2 <= N <= 2 000. Each of the following N lines of input contains one truck type code (a string of seven lowercase letters). You may assume that the codes uniquely describe the trucks, i.e., no two of these N lines are the same. The input is terminated with zero at the place of number of truck types.

Output

For each test case, your program should output the text "The highest possible quality is 1/Q.", where 1/Q is the quality of the best derivation plan.

Sample Input

4
aaaaaaa
baaaaaa
abaaaaa
aabaaaa
0

Sample Output

The highest possible quality is 1/3.

Author

hpustudent

 

 

 

 

 

 

Alphacode

Time Limit : 5000/3000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 23   Accepted Submission(s) : 6
Font: Times New Roman | Verdana | Georgia
Font Size: ← →

Problem Description

将字母A-Z编码,A为1,B为2,……依此类推,Z为26,则ABC编码为123。但是反向解码时,解码结果却不唯一,比如123可以解码为 1-2-3:ABC,解码为12-3:LC,解码为1-23:AW(注意,127不能解码为1-27,因为范围只能为1-26)。

Input

现给出一组编码后的数字串,让你求该数字串可以有几种解码方式(上例中,123对应着3种解码方式)。问题输入将保证其为一个合法的数字串。比如100不是一个合法的数字串,因为0或者00不代表一个字母;此外01不能视为1。

Output

解码方式总数。

Sample Input

25114
1111111111
3333333333

Sample Output

6
89
1

Author

hpustudent
 
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {    
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            String str=sc.next();
            int flag=1;
            int sum=1;
            for(int i=1;i<str.length();i++){
            if(str.charAt(i)=='0'){
                int ss=sum;
                sum=flag;
                flag=ss;
            }    
            else if(cha(str.charAt(i-1)-'0',str.charAt(i)-'0')){
                    int ss=sum;
                    sum+=flag;
                    flag=ss;
                }
            else 
                    flag=sum;
            }
            System.out.println(sum);
        }        
    }
    
    public static boolean cha(int a,int b){
        if(a==0) return false;
        else if(a*10+b<=26) return true;
        
        else return false;
    }
}

1007

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 16   Accepted Submission(s) : 5
Font: Times New Roman | Verdana | Georgia
Font Size: ← →

Problem Description

编写程序,产生由2,3,5这3个数字符号所构成、长度为n的字符串,并且在字符串中对于任何一个子串而言,都不会有相邻的、完全相同的子串;

Input

字符串长度n(1<=n<=15);

Output

无相邻重复子串的所有字符串,每个字符串换行输出。

Sample Input

4

Sample Output

2325
2352
2353
2523
2532
2535
3235
3252
3253
3523
3525
3532
5232
5235
5253
5323
5325
5352

Author

hpustudent
### 天梯赛组队指南及PTA 100-200分题目解答 天梯赛(GPLT,团体程序设计天梯赛)是一项面向高校学生的团体编程竞赛,强调团队合作与算法能力。组队策略和题目解答技巧对于取得好成绩至关重要。 #### 组队策略 1. **团队成员选择** - 团队应由3名成员组成,建议根据成员的技能进行分工。通常可以分为以下三类角色: - **算法专家**:擅长解决复杂算法问题,如动态规划、图论等。 - **编码能手**:擅长快速实现代码,调试能力强,熟悉常用数据结构。 - **逻辑思维者**:擅长解决数学题、逻辑题,能够快速理解题目要求。 - 成员之间应具备良好的沟通能力,能够在比赛中高效协作。 2. **分工与协作** - 比赛中,题目通常分为简单、中等和困难三类。建议团队优先解决简单题目,确保基础分数。 - 对于中等难度题目,团队成员可以分工解决,确保效率最大化。 - 对于困难题目,建议团队共同讨论解决方案,尤其是涉及复杂算法或数据结构的题目。 3. **模拟训练** - 在比赛前,团队应进行多次模拟训练,熟悉比赛环境和题型。 - 模拟训练中可以使用PTA(程序设计在线评测平台)的题目库进行练习,尤其是100-200分的题目。 #### PTA 100-200分题目解答技巧 PTA上的题目按照难度分为不同分数段,100-200分的题目通常涉及以下知识点: 1. **基础数据结构** - 数组、字符串、栈、队列等。 - 示例题目: - PTA 1001 害死人不偿命的(3n+1)猜想 - PTA 1006 换个格式输出整数 2. **数学与逻辑题** - 涉及数论、排列组合、逻辑推理等。 - 示例题目: - PTA 1008 数组元素循环右移问题 - PTA 1011 A+B 和 C 3. **简单算法** - 排序、查找、贪心算法等。 - 示例题目: - PTA 1020 月饼 - PTA 1023 组个最小数 4. **代码实现技巧** - 熟练掌握语言特性,如C++的STL库、Python的列表推导式等。 - 注意代码的可读性和效率,避免不必要的复杂度。 #### 示例代码 以下是一个PTA 100分题目的解答示例(PTA 1001 害死人不偿命的(3n+1)猜想): ```c #include <stdio.h> int main() { int n, count = 0; scanf("%d", &n); while (n != 1) { if (n % 2 == 0) { n /= 2; } else { n = (3 * n + 1) / 2; } count++; } printf("%d", count); return 0; } ``` ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值