杭电校赛(虐哭。。。)

写了半天写三道水题。。。虐哭。。。。

The Country List

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

As the 2010 World Expo hosted by Shanghai is coming, CC is very honorable to be a volunteer of such an international pageant. His job is to guide the foreign visitors. Although he has a strong desire to be an excellent volunteer, the lack of English makes him annoyed for a long time.  Some countries’ names look so similar that he can’t distinguish them. Such as: Albania and Algeria. If two countries’ names have the same length and there are more than 2 same letters in the same position of each word, CC cannot distinguish them. For example: Albania and AlgerIa have the same length 7, and their first, second, sixth and seventh letters are same. So CC can’t distinguish them. Now he has received a name list of countries, please tell him how many words he cannot distinguish. Note that comparisons between letters are case-insensitive.

Input

There are multiple test cases. Each case begins with an integer n (0 < n < 100) indicating the number of countries in the list. The next n lines each contain a country’s name consisted by ‘a’ ~ ‘z’ or ‘A’ ~ ‘Z’. Length of each word will not exceed 20. You can assume that no name will show up twice in the list.

Output

For each case, output the number of hard names in CC’s list.

Sample Input

3
Denmark
GERMANY
China
4
Aaaa
aBaa
cBaa
cBad

Sample Output

2
4

水题。让判断不可区分字符串的个数;

代码:

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<vector>
#include<map>
#include<queue>
const int INF=0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
#define PI(x) printf("%d",x)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define PL(x) printf("%lld",x)
typedef long long LL;
using namespace std;
struct Node{
	char s[25];
	int len;
};
bool js(Node a,Node b){
	int temp=0;
	for(int i=0;i<a.len;i++){
		if(a.s[i]==b.s[i]||abs(a.s[i]-b.s[i])==‘a‘-‘A‘)temp++;
		if(temp>2)return true;
	}
	return false;
}
Node dt[110];
int main(){
	int n;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++)scanf("%s",dt[i].s),dt[i].len=strlen(dt[i].s);
		int ans=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j||dt[i].len!=dt[j].len)continue;
				if(js(dt[i],dt[j])){
					ans++;
					break;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

  

Happy Value

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

In an apartment, there are N residents. The Internet Service Provider (ISP) wants to connect these residents with N – 1 cables.  However, the friendships of the residents are different. There is a “Happy Value” indicating the degrees of a pair of residents. The higher “Happy Value” is, the friendlier a pair of residents is. So the ISP wants to choose a connecting plan to make the highest sum of “Happy Values”.

Input

There are multiple test cases. Please process to end of file. For each case, the first line contains only one integer N (2<=N<=100), indicating the number of the residents. Then N lines follow. Each line contains N integers. Each integer Hij(0<=Hij<=10000) in ith row and jth column indicates that ith resident have a “Happy Value” Hij with jth resident. And Hij(i!=j) is equal to Hji. Hij(i=j) is always 0.

Output

For each case, please output the answer in one line.

Sample Input

2
0 1
1 0
3
0 1 5
1 0 3
5 3 0

Sample Output

1
8

题解:最小生成树模版题,哦,是最大;

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
#define PI(x) printf("%d",x)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define PL(x) printf("%lld",x)
typedef long long LL;
const int MAXN=110;
int mp[MAXN][MAXN];
int ans;
int N;
int low[MAXN];
int vis[MAXN];
void prim(){
	mem(low,INF);mem(vis,0);
	for(int i=1;i<=N;i++)low[i]=mp[1][i];
	vis[1]=1;
	while(true){
		int temp=-INF,k;
		for(int i=1;i<=N;i++)
			if(!vis[i]&&low[i]>temp)temp=low[k=i];
		if(temp==-INF)break;
		vis[k]=1;
		ans+=temp;
		for(int i=1;i<=N;i++)
			if(!vis[i])low[i]=max(low[i],mp[k][i]);
	}
}
int main(){
	while(~scanf("%d",&N)){
		for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++){
			SI(mp[i][j]);
		}
		ans=0;
		prim();
		printf("%d\n",ans);
	}
	return 0;
}

  

The Magic Tower

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

Like most of the RPG (role play game), “The Magic Tower” is a game about how a warrior saves the princess.  After killing lots of monsters, the warrior has climbed up the top of the magic tower. There is a boss in front of him. The warrior must kill the boss to save the princess. Now, the warrior wants you to tell him if he can save the princess.

Input

There are several test cases. For each case, the first line is a character, “W” or “B”, indicating that who begins to attack first, ”W” for warrior and ”B” for boss. They attack each other in turn.  The second line contains three integers, W_HP, W_ATK and W_DEF. (1<=W_HP<=10000, 0<=W_ATK, W_DEF<=65535), indicating warrior’s life point, attack value and defense value.  The third line contains three integers, B_HP, B_ATK and B_DEF. (1<=B_HP<=10000, 0<=B_ATK, B_DEF<=65535), indicating boss’s life point, attack value and defense value. 
Note: warrior can make a damage of (W_ATK-B_DEF) to boss if (W_ATK-B_DEF) bigger than zero, otherwise no damage. Also, boss can make a damage of (B_ATK-W_DEF) to warrior if (B_ATK-W_DEF) bigger than zero, otherwise no damage.

Output

For each case, if boss’s HP first turns to be smaller or equal than zero, please print ”Warrior wins”. Otherwise, please print “Warrior loses”. If warrior cannot kill the boss forever, please also print ”Warrior loses”.

Sample Input

W
100 1000 900
100 1000 900
B
100 1000 900
100 1000 900

Sample Output

Warrior wins
Warrior loses

水题;找用多少时间就可以了,注意特判等于0的情况;

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
#define PI(x) printf("%d",x)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define PL(x) printf("%lld",x)
typedef long long LL;
const double DOT=0.999999999999999;
int main(){
	char s[2];
	int W_h,W_a,W_d,B_h,B_a,B_d;
	while(~scanf("%s",s)){
		scanf("%d%d%d%d%d%d",&W_h,&W_a,&W_d,&B_h,&B_a,&B_d);
		int t1,t2;
		if(W_a<=B_d){
			puts("Warrior loses");
			continue;
		}
		if(B_a<=W_d){
			puts("Warrior wins");
			continue;
		}
		t1=(int)DOT+B_h/(W_a-B_d);
		t2=(int)DOT+W_h/(B_a-W_d);
		int flot=0;
		if(s[0]==‘W‘)flot=1;
		if(t1>t2)puts("Warrior loses");
		else if(t1==t2&&!flot)puts("Warrior loses");
		else puts("Warrior wins");
	}
	return 0;
}

  

时间: 2024-08-25 02:44:46

杭电校赛(虐哭。。。)的相关文章

油菜花王国——杭电校赛(并查集)

油菜花王国 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1609    Accepted Submission(s): 411 Problem Description 程序设计竞赛即将到来,作为学校ACM集训队主力,小明训练一直很努力.今天天气不错,教练也心情大好,破例给各位队员放假一天,小明就骑着自己的小电驴到郊外踏青去了. 出城不

逆袭指数---杭电校赛(暴力搜索)

Problem Description 这依然是关于高富帅小明曾经的故事—— 尽管身处逆境,但小明一直没有放弃努力,除了搬砖,小明还研究过东方的八卦以及西方的星座,一直试图在命理上找到自己能够逆袭的依据. 当这些都失败以后,小明转向了数学研究,希望从中得到一些信息.一天,小明在研究<BestCoder逆袭的数理基础>这本书时,发现了宝贵的信息,其中写道:  每个人都存在一个逆袭指数,对于这个逆袭指数,可能存在连续的因子,如果这个连续因子足够长的话,那么这个人逆袭的概率就很大! 小明已知自己的逆

逆袭指数-——杭电校赛(dfs)

逆袭指数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 626    Accepted Submission(s): 94 Problem Description 这依然是关于高富帅小明曾经的故事—— 尽管身处逆境,但小明一直没有放弃努力,除了搬砖,小明还研究过东方的八卦以及西方的星座,一直试图在命理上找到自己能够逆袭的依据. 当这些都

搬砖--杭电校赛(dfs)

搬砖 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 4646    Accepted Submission(s): 1060 Problem Description 小明现在是人见人爱,花见花开的高富帅,整天沉浸在美女环绕的笙歌妙舞当中.但是人们有所不知,春风得意的小明也曾有着一段艰苦的奋斗史. 那时的小明还没剪去长发,没有信用卡没有她

(2015 杭电校赛 暴力) 逆袭指数

逆袭指数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 626    Accepted Submission(s): 94 Problem Description 这依然是关于高富帅小明曾经的故事—— 尽管身处逆境,但小明一直没有放弃努力,除了搬砖,小明还研究过东方的八卦以及西方的星座,一直试图在命理上找到自己能够逆袭的依据. 当这些都

西电校赛网络赛J题 lucas定理计算组合数

西电校赛网络赛J题  lucas定理计算组合数 问题 J: 找规律II 时间限制: 1 Sec  内存限制: 128 MB 提交: 96  解决: 16 [提交][状态][讨论版] 题目描述 现有数阵如下: 1    2  3   4     5    6 1   3   6  10  15 1   4  10   20 1   5   15 1    6 1 求这个数阵的第n行m列是多少(行列标号从1开始) 结果对10007取模 输入 多组数据,每组数据一行,包含两个整数n,m(1<=n<=

杭电女生赛1001 1002 1003 1005 1008 hdu6023 6024 6025 6027 6030

代码先贴这里 #include "iostream" #include "string.h" #include "stack" #include "queue" #include "string" #include "vector" #include "set" #include "map" #include "algorithm&quo

杭电女生赛1003

题意:给一个序列,删除一个数,令这个序列的gcd最大 思路:求出原始序列的gcd=g,然后从左边跑一遍gcd,如果gcd==c 标记 r,那么a[r] 肯定和前面某个数的gcd为 c , 再从r开始完前跑一遍求gcd,直到gcd==c,标记l,那么a[l]一定与后面(l到r区间)某个数的gcd为 c,所以可得 gcd(a[l],a[r])==c ,分别删除a[l] a[r] 求gcd 输出较大的 PS:给的是任意序列,但是题目第一句话告诉我什么是互质序列是什么鬼,wa了一天以为给的是互质序列,要

第九届西电ACM校赛解答

Description 欢迎参加西电第九届ACM校内赛!作为一名经历了四届校赛的ACM老队员以及本次校赛的出题人,每次校赛都让我有一种全新的感受--有第一次参加校赛时提交代码时紧张到双手发抖,也有当裁判时看到有些不明真相的人提交编译后程序时的欢乐.不管你是第几次参赛,好好享受这一刻带给你的各种感受,经历就是一种财富.为了让大家更好地记住这悲喜交加的日子,特意准备了这么一道题: 给你一个日期,你只要输出这个日期是在校赛前还是校赛后,或者刚好就是校赛那一天(2011年5月22号). 题目是什么意思呢