国际大学生程序设计竞赛试题与分析(一)
ACM国际大学生程序设计竞赛简介

1.ACM国际大学生程序设计竞赛简介1)背景与历史1970年在美国TexasA&M大学举办了首次区域竞赛,从而拉开了国际大学生程序设计竞赛的序幕。
1977年,该项竞赛被分为两个级别:区域赛和总决赛,这便是现代ACM竞赛的开始。
在亚洲、美国、欧洲、太平洋地区均设有区域赛点。
1995至1996年,来自世界各地的一千多支s代表队参加了ACM区域竞赛。
ACM大学生程序设计竞赛由美国计算机协会(ACM)举办,旨在向全世界的大学生提供一个展示和锻炼其解决问题和运用计算机能力的机会,现已成为全世界范围内历史最悠久、规模最大的大学生程序设计竞赛。
2)竞赛组织竞赛在由各高等院校派出的3人一组的队伍间进行,分两个级别。
参赛队应首先参加每年9月至11月在世界各地举行的“区域竞赛(Regional Contest)”。
各区域竞赛得分最高的队伍自动进入第二年3月在美国举行的“总决赛(Final Contest)”,其它的高分队伍也有可能被邀请参加决赛。
每个学校有一名教师主管队伍,称为“领队”(faculty advisor),他负责选手的资格认定并指定或自己担任该队的教练(coach)。
每支队伍最多由三名选手(contestant)组成,每个选手必须是正在主管学校攻读学位的学生。
每支队伍最多允许有一名选手具有学士学位,已经参加两次决赛的选手不得再参加区域竞赛。
3)竞赛形式与评分办法竞赛进行5个小时,一般有6~8道试题,由同队的三名选手使用同一台计算机协作完成。
当解决了一道试题之后,将其提交给评委,由评委判断其是否正确。
若提交的程序运行不正确,则该程序将被退回给参赛队,参赛队可以进行修改后再一次提交该问题。
程序运行不正确是指出现以下4种情况之一:(1)运行出错(run-time error);(2)运行超时〔time-limit exceeded〕;(3)运行结果错误(wrong answer);(4)运行结果输出格式错误(presentation error)。
ACM国际大学生程序设计竞赛吉林大学选拔赛

ACM国际大学生程序设计竞赛吉林大学选拔赛暨吉林大学第一届程序设计竞赛竞赛宗旨进入二十一世纪以来,计算机与信息技术正在全球以令人难以置信的速度突飞猛进, 计算机应用发展水平已经成为国家竞争力的重要标志,网络与知识经济受到了世界各国政府的高度重视。
发展计算机和信息产业的关键在于培养高素质人才。
对一流人才的培养和竞争已成为各国政府、学校和科研机构、各大公司等的头等重要的战略任务。
在此宏观背景下,各种旨在考察学生计算机应用能力的校内、国内、国际竞赛为选拔和培养高素质人才提供了广阔的舞台。
ACM/ICPC作为具有国际权威性和影响力的国际大学生程序设计竞赛,已成为衡量大学生程序设计能力和学校计算机学科水平的重要标准之一。
ACM/ICPC 比赛是学校教务处组织的重点学生科技竞赛活动,是培养学生创新精神和能力的组成部分,受到全校同学的热切关注。
吉林大学2002年首次组队参赛,取得了较为理想的成绩。
为丰富校园学术气氛,进一步提高我校同学的计算机编程实践能力,鼓励和培养具有创新思维的人才,提供给更多学生展示自己才能的机会。
我校将举办2003年ACM/ICPC选拔赛暨吉林大学首届程序设计竞赛。
本次比赛由吉林大学教务处、吉林大学计算机科学与技术学院主办,旨在从全校同学中选拔优秀的程序设计人才,作为新一届吉林大学ACM竞赛代表队的预备队员代表学校参加全国比赛,并对优秀选手进行奖励竞赛计划于2003年4月13日在吉林大学前卫校区举行。
竞赛组织竞赛由学校教务处和计算机科学与技术学院共同组成ACM/ICPC竞赛委员会,负责竞赛组织、指导和具体问题安排。
组长:赵继副组长:张长海、房蔓楠成员:戴继周、罗辉竞赛委员会下设竞赛裁判组,由郭东伟负责;竞赛常务组,由李强负责。
同时邀请吉林大学计算机领域知名专家组成顾问组。
成员:鞠九滨、金成植、周春光、孙吉贵、刘磊竞赛联系地点在前卫校区萃文楼443,联系电话5166476-3,联系人:郭东伟、李强。
ACM国际大学生程序设计大赛相关知识

ACM国际大学生程序设计大赛相关知识ACM国际大学生程序设计竞赛ACM国际大学生程序设计竞赛(英文全称:ACM International Collegiate Programming Contest(ACM-ICPC或ICPC)是由美国计算机协会(ACM)主办的,一项旨在展示大学生创新能力、团队精神和在压力下编写程序、分析和解决问题能力的年度竞赛。
经过近30多年的发展,ACM国际大学生程序设计竞赛已经发展成为最具影响力的大学生计算机竞赛。
赛事目前由IBM公司赞助。
历史竞赛的历史可以上溯到1970年,当时在美国得克萨斯A&M大学举办了首届比赛。
当时的主办方是the Alpha Chapter of the UPE Computer Science Honor Society。
作为一种全新的发现和培养计算机科学顶尖学生的方式,竞赛很快得到美国和加拿大各大学的积极响应。
1977年,在ACM计算机科学会议期间举办了首次总决赛,并演变成为目前的一年一届的多国参与的国际性比赛。
迄今已经举办了29届。
最初几届比赛的参赛队伍主要来自美国和加拿大,后来逐渐发展成为一项世界范围内的竞赛。
特别是自1997年IBM开始赞助赛事之后,赛事规模增长迅速。
1997年,总共有来自560所大学的840支队伍参加比赛。
而到了2004年,这一数字迅速增加到840所大学的4109支队伍并以每年10-20%的速度在增长。
1980年代,ACM将竞赛的总部设在位于美国得克萨斯州的贝勒大学。
在赛事的早期,冠军多为美国和加拿大的大学获得。
而进入1990年代后期以来,俄罗斯和其它一些东欧国家的大学连夺数次冠军。
来自中国大陆的上海交通大学代表队则在2002年美国夏威夷的第26届和2005年上海的第29届全球总决赛上两夺冠军。
这也是目前为止亚洲大学在该竞赛上取得的最好成绩。
赛事的竞争格局已经由最初的北美大学一枝独秀演变成目前的亚欧对抗的局面。
国际大学生程序设计大赛(ACM-icpc)输入输出介绍

本类输入解决方案:
C语法: scanf("%d",&n) ; for( i=0 ; i<n ; i++ ) { .... } C++语法: cin >> n; for( i=0 ; i<n ; i++ ) { .... }
2012-3-26 12
输入第三类:
输入不说明有多少个Input Block,但以某个特殊输入为结束标志。 ex-3
2012-3-26 10
ex-2源代码:
#include <stdio.h> int main() { int n,i,a,b; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d",&a, &b); printf("%d\n",a+b); } }
2012-3-26 11
ACM程序设计
输入输出格式
2012-3-26
1
ACM题目特点
由于ACM竞赛题目的输入数据和输出 数据一般有多组(不定),并且格式多 种多样,所以,如何处理题目的输入输 出是对大家的一项最基本的要求。这也 是困扰初学者的一大问题。 下面,分类介绍:
2012-3-26
2
一个超级简单的题目(ex-1):
5
输入第一类:
输入不说明有多少个Input Block, 以EOF为结束标志。 参见:ex-1.
2012-3-26
6
ex-1源代码:
#include <stdio.h> int main() { int a,b; while(scanf("%d %d",&a, &b) != EOF) printf("%d\n",a+b); }
大学生程序设计竞赛试题(正式赛)

中原工学院第一届大学生程序设计竞赛正式比赛试题主办:中原工学院教务处学生处校团委计算机学院承办:中原工学院计算机学院地点:计算机学院实验中心406实验室时间:2010年4月11日【试题一】兔子【题目描述】兔子具有很强的繁殖能力。
一对成年兔子每个月可以繁殖一对小兔子,而一对小兔子经过m个月之后,就会长成一对成年兔子。
通过分析,我们可以看出:若m=2的时候,每个月兔子的对数构成了一个Fibonacci数列。
但是,若m<>2,这个问题看起来就不那么简单了。
你的任务是计算:假定初始只有一对兔子,那么,经过d个月之后,共有多少对兔子?可以假定,在此阶段没有任何兔子死亡。
【输入】输入包括多组测试数据。
每组测试数据的一行中包括2个整数m(1<=m<=10),d(1<=d<=30)。
当测试数据遇到一行中有两个0时,即m=d=0,测试数据结束。
【输出】针对每组测试数据,在每一行输出经过d个月后共有多少对兔子。
【输入样例】2 33 50 0【输出样例】59【试题二】网页浏览器【题目描述】Mozilla Firefox是一个自由的,开放源码的网页浏览器,适用于Windows, Linux 和MacOS X等平台。
Firefox火狐校园大使是Mozilla开源社区项目的一部分,针对在校的高年级本科生和研究生以及众多技术爱好者,在校园中推广开源项目和开放技术,让更多的开发人员受益于Mozilla的开放技术和免费资源。
你很荣幸得到了这样一个机会,为Firefox编写一个重要的导航模块。
正如上图所示,导航模块要接受用户的后退、前进、进入用户输入的网址以及清空浏览记录等操作。
【输入】为了简化问题,用户所有的操作都以字符的形式从标准输入读入。
每一行描述一个操作,各操作的格式和功能如下所示:操作功能back 如果当前页面不是第一个页面,则跳到到前一个页面,并输出这个页面的网址forward 如果当前页面不是最后一个页面,则跳到到后一个页面,并输出这个页面的网址url 网址跳转到用户输入的网址(网址不含空格)clear 清空浏览记录(当前页面除外)exit 退出浏览器浏览器启动时默认进入中原工学院的主页” ”【输出】对于每一个需要输出网址的操作,输出对应的网址。
ACM 国际大学生程序设计竞赛(ICPC) 规则

ACM 国际大学生程序设计竞赛(ICPC) 规则.txt其实全世界最幸福的童话,不过是一起度过柴米油盐的岁月。
一个人愿意等待,另一个人才愿意出现。
感情有时候只是一个人的事,和任何人无关。
爱,或者不爱,只能自行了断。
发信人: delphiking (brenda), 信区: ACM_ICPC 标题: ACM 国际大学生程序设计竞赛(ICPC) 规则发信站: 兵马俑BBS (Mon Aug 22 10:45:30 2005), 本站(202.117.1.8)ACM 国际大学生程序设计竞赛(ICPC) 规则竞赛宗旨ACM国际大学生程序设计竞赛(ICPC)是由ACM协会提供给大学生的一个展示和提高解题与编程能力的机会。
ACM国际大学生程序设计竞赛亚洲赛区邀请亚洲学生参加,以增进友谊,开展编程方面的公平竞赛。
地区预赛组织ACM竞赛中由代表高等教育机构的学生组队参加2-4轮比赛,首先是每年10月至12月举行的地区预赛,每个赛区的第一名队伍自动取得参加决赛的资格。
(地区预赛前的选拔规则参见下一章《地区二级预赛和学校选拔赛》)国际大学生程序设计竞赛的规则由ACM世界竞赛决赛指导委员会制订。
其中,竞赛主任是负责人,由竞赛主任独立负责解释竞赛规则。
当遇到无法预料的情况时,竞赛主任有权作出最终决定。
亚洲地区包括亚洲所有的地区和国家,例如香港、台湾、韩国、朝鲜、日本、中国、新加坡、马来西亚、泰国、菲律宾、印度尼西亚、印度、斯里兰卡、缅甸、越南、土耳其、澳门,蒙古、西伯利亚地区、巴基斯坦、孟加拉国、中亚地区、以色列、伊朗以及中东国家等。
亚洲赛区在地区竞赛主任的指导下进行管理。
在获得竞赛主任的同意的前提下,由地区竞赛主任负责执行亚洲赛区的规则和指导方针。
每年由地区竞赛主任在亚洲选择几个比赛地点举办亚洲赛区的竞赛,地区竞赛主任根据ACM国际大学生程序设计竞赛指导方针负责计划、组织和举行亚洲赛区的比赛。
亚洲赛区不按照政治概念来分割赛区,参加决赛的队伍代表学校,而不代表政治概念上的地区。
【综合】Acm竞赛简介

Parity(ceoi99)(肖天)
• 建立sum数组,sum[i]表示从1到i之和是奇(true)还是偶 (false),sum[0]=false。这样题目中给的任意问题(a,b) 的答案都可以用sum[b] xor sum[a-1]表示。 • 开始我们并不知道sum[1..n]的值,不妨设为false,这时任意 sum[a],sum[b]都是独立的。对于每对问答(a,b,c),都可以 知道sum[b] xor sum[a-1]=c,由此把sum[b]和sum[a-1] 联系起来。这步操作可以用并查集完成,对于问答(a,b,c)如 果sum[a-1],sum[b]不属于一个集合就把它们并起来,否则 如果sum[a-1] xor sum[b]不等于c则说明出现矛盾,输出总 句数,退出。 • 对于不出现矛盾的sum数组,对于每个集合分为两个部分,我 们指定其中一个部分为true,另一个部分为false,则可以确定 sum数组,利用sum[i] xor sum[i-1]可以求出第i位的数字, 由于不同集合之间没有问答出现,所以此数列是一可行解,证 明算法正确。
• 但有时却是最好的办法
22
Pizza Anyone? (ZOJ 1219)
• 题目大意: 你需要为你和你的朋友们订一个皮萨。 每个朋友都会告诉你他们想和不想放进皮萨 里的东西。 你是否能订一个皮萨,让他满足每个人 至少一个条件。 假设一共有16种东西可以放进皮萨。
23
2 65536
16
是个对计算机很 小的数
3
ACM
ACM (Association for Computing Machinery) 成立于计算机诞生次年,是目前计算机学界中历史最 悠久、最具权威性的组织,是推进信息技术专业人员 和学生提高技巧的主要力量。ACM通过提供前沿技 术信息和从理论到实践的转化,为其全球7.5万名成 员服务,并已经成为信息科技领域的一个基本信息来 源。
第八届程序设计大赛初赛试题及答案

第八届程序设计大赛初赛试题说明:请将所有答案写到试卷第1页及第2页。
一、读程序写结果(40分)1、(5分)2、(5分)3、(10分)结果:结果:结果:4、(10分)5、(5分)6、(5分)结果:结果:结果:二、代码填空(30分)1、(5分)2、(5分)空一:____acm / lg (5分)空一:if(begin>end) return (5分)3、(12分)4、(8分)空一:siruan /= 10 (3分)空一:s[i] - '0' (4分)空二:hm - lg (3分)空二:siruan[sum % 11] (4分)空三:lghm = acm(lghm) (6分)三、思维题(15分)数据1:T1=1,T2=2,T3=3,T4 = 4 数据2:T1=1,T2=2,T3=5,T4 = 10 答案:(acm)1 2->(siruan) 2min 答案:(acm)1 2->(siruan) 2min (acm) <-1 (siruan) 1min (acm) <-1 (siruan) 1min(acm) 1 3->(siruan) 3min (acm) 5 10->(siruan) 10min(acm) <-1 (siruan) 1min (acm) <-2 (siruan) 2min(acm) 1 4-> (siruan) 4min (acm) 1 2-> (siruan) 2min最短时间:2+1+3+1+4 = 11min 最短时间:2+1+10+2+2 = 17min数据3:T1 = 5,T2 = 2,T3=1,T4=10,T5=8 答案:(acm)1 2->(siruan) 2min(acm) <-1 (siruan) 1min(acm) 8 10->(siruan) 10min(acm) <-2 (siruan) 2min(acm) 1 2-> (siruan) 2min(acm) <-1 (siruan) 1min(acm) 1 5 ->(siruan) 5min最短时间:2+1+10+2+2+1+5 = 23min四、编程题(15分)程序代码:#include<stdio.h>#include<string.h>int s[110];int main(){int i;int a, n, m;while (scanf("%d%d", &a, &n)!=EOF){memset(s, 0x00, sizeof(s));m = n;for (i=0; i<m; i++){s[i] += a * (n--);s[i+1] = s[i] / 10;s[i] %= 10;}if (s[m]) printf("%d", s[i]);for (i=m-1; i>=0; i--)printf("%d", s[i]);printf("\n");}return 0;}一、读程序写结果(40分)1、(5分)#include <stdio.h>int main(){char acm[] = "I love acm!";char siruan[] = "I love siruan!";char def[] = "Welcome to join us!";int chose = 0;switch (chose){case 0: printf("%s\n", acm);case 1: printf("%s\n", siruan);default : printf("%s", def);}return 0;}输出结果:2.(5分)#include <stdio.h>int main(){int acm = 0, siruan = 1;if (acm = siruan) printf("%s", "May you success!");else printf("%s", "May you success,too!");return 0;}输出结果:3.(10分)#include <stdio.h>#include <math.h>int main(){int i,j,k,n;char lghm[14]="ILOVEACMSIRUAN";n = 3;for (i=0; i<n-1; i++) printf(" ");printf("%c\n",lghm[0]);for (i=1; i<n; i++){for (j=abs(n-i-1); j>0; j--) //abs(n)返回值为整形n的绝对值printf(" ");printf("%c",lghm[2*i-1]);for (k=1; k<=2*i-1; k++) printf(" ");printf("%c\n",lghm[2*i]);}for (i=n; i<=2*n-3; i++){for (j=abs(n-i-1); j>0; j--) printf(" ");printf("%c",lghm[2*i-1]);for (k=1; k<=4*n-5-2*i; k++) printf(" ");printf("%c\n",lghm[2*i]);}for (i=0; i<n-1; i++) printf(" ");printf("%c\n",lghm[4*n-5]);return 0;}输出结果:4.(10分)#include <stdio.h>#include <string.h>struct Student{char name[20];int num;} stu[5];{stu[0].num = 521; strcpy(stu[0].name, "sichuan wenchuan");stu[1].num = 521; strcpy(stu[1].name, "bless");stu[2].num = 420; strcpy(stu[2].name, "sichuan yaan");stu[3].num = 420; strcpy(stu[3].name, "love");stu[4].num = 420; strcpy(stu[4].name, "god");}void swap(int a, int b){struct Student tmp;tmp.num = stu[a].num;stu[a].num = stu[b].num;stu[b].num = tmp.num;strcpy(, stu[a].name);strcpy(stu[a].name, stu[b].name);strcpy(stu[b].name, );}void bubble_sort(int n){int i,j,flag,temp;for(i = 0; i < n-1; i++){flag = 1;for(j = 0; j < n-i-1; j++){if(stu[j].num > stu[j+1].num){swap(j, j+1);flag = 0;}else if (stu[j].num == stu[j+1].num && strcmp(stu[j].name,stu[j+1].name)<0){ swap(j, j+1);}}if(flag) break;}}int main(){init();bubble_sort(5);for (i=0; i<5; i++)printf("%-4d%s\n", stu[i].num, stu[i].name);return 0;}输出结果:6.(5分)#include <stdio.h>int acm(){int lg = 1314520;int hm = 0;while(lg > 0){hm = hm * 10 + lg % 10;lg /= 10;}return hm;}int main(){int siruan = acm();printf("%d", siruan);return 0;}输出结果:二、代码填空(30分)1.(5)如果没有计算器,我们如何求3的平方根?可以先猜测一个数,比如1.5,然后用3除以这个数字。
“知乎杯”2018CCF大学生计算机系统与程序设计竞赛贪心算法(greedy)

“知乎杯”2018CCF⼤学⽣计算机系统与程序设计竞赛贪⼼算法(greedy)-->贪⼼算法1)题解•分别⽤V0、V1和V>=2表⽰度为0、1以及⾄少为2的顶点集合•对于每个顶点,维护三个属性:•degree 邻居的个数•degree2邻居中度为2的顶点数•id 编号Pseudo-code•initialize V0, V1, V>=2 and (degree, degree2, id) of each node•while G is not empty•if V0 is not empty•choose v ∈ V0 with the smallest id•output v, delete v from V0 and G•else if V1 is not empty•choose v ∈ V1 with the smallest id, and find the neighbor u of v•output v, delete v from V0 and G, delete u from V1(or V>=2) and G•else•choose v ∈ V>=2 with the largest (degree, degree2, id)•delete v from V>=2 and G索引的维护•需要注意的是,每个顶点的属性以及顶点集合V0、V1和V>=2并⾮⼀成不变。
•当从图中删去某个顶点u时,u邻居的degree均会减⼀;如果u的degree恰好为2,那么u邻居的degree2也会减⼀。
•如果某个邻居v的degree恰好从3减少到2或从2减到1,那么还会进⼀步影响到v的邻居的degree2属性。
•对于那些degree减⼀的顶点,还需要相应地更新V0、V1和V>=2。
Delete Node u from G•for v ∈ Neighbor(u)•v.degree decreases by one•if u.degree == 2 then v.degree2 decreases by one•if v.degree == 0•move v from V1 to V0•else if v.degree == 1•move v from V>=2 to V1•find the only neighbor w of v•w.degree2 decreases by one•else if v.degree == 2•for w ∈ Neighbor(v) do w.degree2 increases by one2)复杂度分析V0和V1 {node_id}•插⼊、删除顶点,但每个顶点最多⼀次;•查询id最⼩的顶点。
大学生程序设计竞赛研究与实践

一
、
引言
如 果 多支 队伍 解题 数量 相 同 ,则根 据解 题 总时 间短 的优先 胜 出 ,
A M 国 际 大 学 生 程 序 设 计 竞 赛 ( C I tra in l C A M n en to a C le it r gam n o t s ,简称 AM IP )是 由 AM组 o lg a eP or m igCn e t C/ CC c
每 错误 提 交一 次要 增加 惩 罚时 间 。正确 解题 数最 多且 总用 时最 少
的队伍 为 冠军 。
织 的年 度性 竞 赛 ,它始 于 17 ,是全 球 大学 生展 示编 程 能力 、 90年 解 决 问题 能力 和 团 队合 作 能力 的平 台 。 17 年举 办 了首届 总 决 97
30多支 队伍 近 10 人 参赛 。本专科 学 生 同堂参 赛 ,分 开划 分 等 0 00 级 ,高 职学 生也 参 与 了这个 AM竞 赛平 台,约 占参 赛总 人数 的三 C
ACM比赛试题

The 35th ACM-ICPC Asia Regional Contest (Hangzhou)Contest SectionOctober 24, 2010Sponsored by IBM & AlibabaZhejiang Sci-Tech UniversityThis problem set should contain 10 problems on numbered 24 pages. Please inform a runner immediately if something is missing from your problem set.Problem A. Naughty fairiesDescriptionOnce upon a time, there lived a kind of fairy in the world. Those fairies could hear the voice of fruit trees, and helped people with a harvest. But people did n’t know that fruits are also those fairies’ favorite food. After the fairies ate people’s fruits, they always did something to cover it up.One day a little fairy named Lily flew into an orchard and found a large peach tree. Hungry as Lily was, she started eating without thinking until her stomach was full. In the fairy world, when a fairy ate the fruits in a fruit tree, sometimes the fruit tree would feel honored and bore more fruits immediately. That’s why sometimes the number of fruits in a tree got increased after a fairy ate fruits of that tree.But the fairies didn’t want people to find out weird things such as fruits become more or less suddenly. Lily decided to use a magic spell so that the orchard owner couldn’t find the change of the number of p eaches.Suppose there were N peaches on a tree originally and there were M peaches left after Lily was full. M may be greater than, less than or equal to N. All M peaches were visible at first, and Lily wanted to make an illusion so that exactly N peaches are visible.Lily can do 3 kinds of spell to change the total visible number of peaches:1) “PAPADOLA”:This spell would increase the number of visible peaches by one.2) “EXPETO POTRONUM”:This spell would double the number of visible peaches.3) “SAVIDA LOHA”:This spell would decrease the number of visible peaches by one. Each spell would take one minute and Lily wanted to finish as fast as possible. Now please tell Lily the least time she needs to change the number of visible peaches to N.InputThere are several test cases, ended by “0 0”.For each test case, there are only one line containing two numbers separated by a blank, N and M, the original numbers of peaches and the numbers of peaches left(0<N,M<10500).There is no leading zero.OutputFor each test case, you should output just a number K indicating the minimum time (in minutes) Lily needed to finish her illusion magic.Sample Input5 21 9986 320 0Sample Output29812Problem B. Prison BreakDescriptionRompire is a robot kingdom and a lot of robots live there peacefully. But one day, the king of Rompire was captured by human beings. His thinking circuit was changed by human and thus became a tyrant. All those who are against him were put into jail, including our clever Micheal#1. Now it’s time to escape, but Micheal#1 needs an optimal plan and he contacts you, one of his human friends, for help.The jail area is a rectangle contains n×m little grids, each grid might be one of the following:1) Empty area, represented by a capital letter ‘S’.2) The starting position of Micheal#1, represented by a capital letter ‘F’.3) Energy pool, represented by a capital letter ‘G’. When entering a n energy pool, Micheal#1 can use it to charge his battery ONLY ONCE. After the charging, Micheal#1’s batt ery will become FULL and the energy pool will become an empty area. Of course, passing an energy pool without using it is allowed.4) Laser sensor, represented by a capital letter ‘D’. Since it is extremely sensitive, Micheal#1 cannot step into a grid with a laser sensor.5) Power switch, represented by a capital letter ‘Y’. Once Micheal#1 steps into a grid with a Power switch, he will certainly turn it off.In order to escape from the jail, Micheal#1 need to turn off all the power switches to stop the electric web on the roof—then he can just fly away. Moving to an adjacent grid (directly up, down, left or right) will cost 1 unit of energy and only moving operation costs energy. Of course, Micheal#1 cannot move when his battery contains no energy.The larger the battery is, the more energy it can save. But larger battery means more weight and higher probability of being found by the weight sensor. So Micheal#1 needs to make his battery as small as possible, and still large enough to hold all energy he need. Assuming that the size of the battery equals to maximum units of energy that can be saved in the battery, and Micheal#1 is fully charged at the beginning, Please tell him the minimum size of the battery needed for his Prison break.InputInput contains multiple test cases, ended by 0 0. For each test case, the first line contains two integer numbers n and m showing the size of the jail. Next n lines consist of m capital letters each, which stands for the description of the jail.You can assume that 1<=n,m<=15, and the sum of energy pools and power switches is less than 15.OutputFor each test case, output one integer in a line, representing the minimum size of the battery Micheal#1 needs. If Micheal#1 can’t escape, output -1.Sample Input5 5GDDSSSSSFSSYGYSSGSYSSSYSS0 0Sample Output4Problem C. To Be an Dream Architect DescriptionThe “dream architect” is the key role in a team of “dream extractors” who enter other’s dreams to steal secrets. A dream architect is responsible for crafting the virtual world that the team and the target will dream into. To avoid the target noticing the world is artificial, a dream architect must have powerful 3D imagination.Cobb uses a simple 3D imagination game to test whether a candidate has the potential to be an dream architect. He lets the candidate imagine a cube consisting of n×n×n blocks in a 3D coordinate system as Figure 1. The block at bottom left front corner is marked (1, 1, 1) and the diagonally opposite block is marked (n, n, n). Then he tells the candidate that the blocks on a certain line are eliminated. The line is always parallel to an axis. After m such block eliminations, the candidate is asked to tell how many blocks are eliminated. Note that one block can only be eliminated once even if it is on multiple lines.Here is a sample graph according to the first test case in the sample input:InputThe first line is the number of test cases.In each test case, the first line contains two integers n and m( 1 <= n <= 1000, 0 <= m <= 1000).,meaning that the cube is n x n x n and there are m eliminations.Each of the following m lines represents an elimination in the following format:axis_1=a, axis_2=bwhere axis_i (i=1, 2) is ‘X’ or ‘Y’, or ‘Z’ and axis_1 is not equal to axis_2. a and b ar e 32-bit signed integers.OutputFor each test case output the number of eliminated blocks.Sample Input23 2Y=1,Z=3X=3,Y=110 2X=3,Y=3Y=3,Z=3Sample Output519Problem D. GomokuDescriptionYou are probably not familiar with the title, “Gomoku”, but you must have played it a lot. Gomoku is an abstract strategy board game and is also called Five in a Row, or GoBang. It is traditionally played with go pieces (black and white stones) on a go board (19x19 intersections). Nowadays, standard chessboard of Gomoku has 15x15 intersections. Black plays first, and players alternate in placing a stone of their color on an empty intersection. The winner is the first player to get an unbroken row of five or more stones horizontally, vertically, or diagonally.For convenience, we coordinate the chessboard as illustrated above. The left-bottom intersection is (0,0). And the bottom horizontal edge is x-axis, while the left vertical line is y-axis.I am a fan of this game, actually. However, I have to admit t hat I don’t have a sharp mind. So I need a computer program to help me. What I want is quite simple. Given a chess layout, I want to know whether someone can win within 3 moves, assuming both players are clever enough. Take the picture above for example. There are 31 stones on it already, 16 black ones and 15 white ones. Then we know it is white turn. The white player must place a white stone at (5,8). Otherwise, the black player will win next turn. After that, however, the white player also gets a perfect situation that no matter how his opponent moves, he will win at the 3rd move.So I want a program to do similar things for me. Given the number of stones and positions of them, the program should tell me whose turn it is, and what will happen within 3 moves.InputThe input contains no more than 20 cases.Each case contains n+1 lines which are formatted as follows.nx1 y1 c1x2 y2 c2......x n y n c nThe first integer n indicates the number of all stones. n<=222 which means players have enough space to place stones. Then n lines follow. Each line contains three integers: x i and y i and c i. x i and y i are coordinates of the stone, and ci means the color of the stone. If c i=0 the stone is white. If c i=1 the stone is black. It is guaranteed that 0<=x i,y i<=14, and c i=0 or 1. No two stones are placed at the same position. It is also guaranteed that there is no five in a row already, in the given cases.The input is ended by n=0.OutputFor each test case:First of all, the program should check whose turn next. Le t’s call the player who will move next “Mr. Lucky”. Obviously, if the number of the black stone equals to the number of white, Mr. Lucky is the black player. If the number of the black stone equals to one plus the numbers of white, Mr. Lucky is the white player. If it is not the first situation or the second, print “Invalid.”A valid chess layout leads to four situations below:1)Mr. Lucky wins at the 1st move. In this situation, print :Place TURN at (x,y) to win in 1 move.“TURN” must be replaced by “black” or “white” according to the situation and (x,y) is the position of the move. If there are different moves to win, choose theone where x is the smallest. If there are still different moves, choose the one where y is the smallest.2)Mr. Lucky’s opp onent wins at the 2nd move. In this situation, print:Lose in 2 moves.3)Mr. Lucky wins at the 3rd move. If so, print:Place TURN at (x,y) to win in 3 moves.“TURN” should replaced by “black” or “white”, (x,y) is the position where the Mr.Lucky should place a stone at the 1st move. After he place a stone at (x,y), no matter what his opponent does, Mr. Lucky will win at the 3rd step. If there are multiple choices, do the same thing as described in situation 1.4)Nobody wins within 3 moves. If so, print:Cannot win in 3 moves.Sample Input313 3 13 4 03 5 03 6 04 4 14 5 14 7 05 3 05 4 05 5 15 6 15 7 15 9 16 4 16 5 16 6 06 7 16 8 06 9 07 5 17 6 07 7 17 8 17 9 08 5 08 6 18 7 08 8 18 9 09 7 110 8 017 7 117 7 0Sample OutputPlace white at (5,8) to win in 3 moves. Cannot win in 3 moves.Invalid.Problem E. GunshotsDescriptionPresident Bartlet was shot! A group of terrorists shot to the crowd when President Bartlet waved to cheering people after his address. Many people were shot by the irrational bullets. Senior FBI agent Don Epps takes responsibility for this case. According to a series of crime scene investigation, including analyzing shot shells, replaying video from closed-circle television and collecting testimony by witnesses, Don keeps all the information about where and how the terrorists shot to crowd, as well as the location of every single person when the gun shoot happened. Now he wants to know how many gunshot victims are there in this case.Imagine that each target person can be regarded as a polygon (can be concave or self-intersecting) and each gunshot can be regarded as a half-line. The bullet will be stopped by the first person it shoots. A person can be shot in three ways:To simplify the problem, we assume that any two polygons can be completely separated by a line. Also each start point of the gunshot can be separated from each polygon by a line. Now given M people and N gunshots, please work out which person has been shot by each bullet.InputThere are multiple test cases in the input. The first line of the input file is an integer T demonstrating the number of test cases. (T<=10).For each test case, the first line is an integer N, representing the number of people (polygons). Following lines demonstrates the polygons. For the i th polygon (0<=i<N), the first line is an integer Q i , representing the number of edges of this polygon. In each of the following Q i lines, there are two real numbers x i and y i representing a point. Every pair of adjacent points demonstrate an edge of this polygon (i.e. (x i , y i ) to (x i+1, y i+1) is an edge, in which 0<=i<Q i -1), and (x Qi-1, y Qi-1) to (x 0, y 0) also demonstrates an edge of this polygon.PersonPerson Person 1. Normal shot 2. The bullet’s path isparallel to an edge 3. The bullet’s path is tangent to an vertexThen there is a line contains an integer M representing the number of gunshots. In the following M lines, each line contains four real numbers x, y, dx and dy, representing the start point (x, y) and direction vector (dx, dy) of that gunshot.In all test cases, we assume that 0< N<=100, 0<Q i<=1000, 0<M<=10000.OutputFor each test case, output contains M lines and the i th line demonstrates the result of the i th gunshot.If the i th gunshot shoots the j th polygon, the i th line contains “HIT j”, otherwise it contains a word “MISS” (means that it does not shoot any target). The polygons are numbered in the order of their appearance in the input file, and the numbers start from 0.At the end of each test case, please output a single line with “*****”.Sample Input1140 01 10 11 02-1 0 1 0-2 0 -1 0Sample OutputHIT 0MISS*****HintThe figure of the first case in the samples is as follows:Problem F. Rotational PaintingDescriptionJosh Lyman is a gifted painter. One of his great works is a glass painting. He creates some well-designed lines on one side of a thick and polygonal glass, and renders it by some special dyes. The most fantastic thing is that it can generate different meaningful paintings by rotating the glass. This method of design is called “Rotatio nal Painting (RP)” which is created by Josh himself.You are a fan of Josh and you bought this glass at the astronomical sum of money. Since the glass is thick enough to put erectly on the table, you want to know in total how many ways you can put it so that you can enjoy as many as possible different paintings hiding on the glass. We assume that material of the glass is uniformly distributed. If you can put it erectly and stably in any ways on the table, you can enjoy it.More specifically, if the polygonal glass is like the polygon in Figure 1, you have just two ways to put it on the table, since all the other ways are not stable. However, the glass like the polygon in Figure 2 has three ways to be appreciated.Pay attention to the cases in Figure 3. We consider that those glasses are not stable.InputThe input file contains several test cases. The first line of the file contains an integer T representing the number of test cases.For each test case, the first line is an integer n representing the number of lines of the polygon. (3<=n<=50000). Then n lines follow. The i th line contains two real number x i and y i representing a point of the polygon. (x i, y i) to (x i+1, y i+1) represents a edge of the polygon (1<=i<n), and (x n,y n) to (x1, y1) also represents a edge of the polygon. The input data insures that the polygon is not self-crossed.OutputFor each test case, output a single integer number in a line representing the number of ways to put the polygonal glass stably on the table.Sample Input240 0100 099 11 160 00 101 101 110 110 0Sample Output23HintThe sample test cases can be demonstrated by Figure 1 and Figure 2 in Description part.Problem G. Traffic Real Time Query System DescriptionCity C is really a nightmare of all drivers for its traffic jams. To solve the traffic problem, the mayor plans to build a RTQS (Real Time Query System) to monitor all traffic situations. City C is made up of N crossings and M roads, and each road connects two crossings. All roads are bidirectional. One of the important tasks of RTQS is to answer some queries about route-choice problem. Specifically, the task is to find the crossings which a driver MUST pass when he is driving from one given road to another given road.InputThere are multiple test cases.For each test case:The first line contains two integers N and M, representing the number of the crossings and roads.The next M lines describe the roads. In those M lines, the i th line (i starts from 1)contains two integers X i and Y i, representing that road i connects crossing X i and Y i (X i≠Y i).The following line contains a single integer Q, representing the number of RTQs. Then Q lines follows, each describing a RTQ by two integers S and T(S≠T) meaning that a driver is now driving on the road s and he wants to reach road t . It will be always at least one way from road s to road t.The input ends with a line of “0 0”.Please note that: 0<N<=10000, 0<M<=100000, 0<Q<=10000, 0<X i,Y i<=N, 0<S,T<=M OutputFor each RTQ prints a line containing a single integer representing the number of crossings which the driver MUST pass.Sample Input5 61 22 33 44 53 522 32 40 0Sample Output 01Problem H. National Day ParadeDescriptionThere are n×n students preparing for the National Day parade on the playground. The playground can be considered as a n×m grid. The coordinate of the west north corner is (1,1) , and the coordinate of the east south corner is (n,m).When training, every students must stand on a line intersection and all students must form a n×n square. The figure above shows a 3×8 playground with 9 students training on it. The thick black dots stand for the students. You can see that 9 students form a 3×3 square.After training, the students will get a time to relax and move away as they like. To make it easy for their masters to control the training, the students are only allowed to move in the east-west direction. When the next training begins, the master would gather them to form a n×n square again, and the position of the square doesn’t matter. Of course, no student is allowed to stand outside the playground.You are given the coordinates of each student when they are having a rest. Your task is to figure out the minimum sum of distance that all students should move to form a n×n square.InputThere are at most 100 test cases.For each test case:The first line of one test case contain two integers n,m. (n<=56,m<=200)Then there are n×n lines. Each line contains two integers, 1<=X i<=n,1<= Y i<=m indicating that the coordinate of the i th student is (X i , Y i ). It is possible for more than one student to stand at the same grid point.The input is ended with 0 0.OutputYou should output one line for each test case. The line contains one integer indicating the minimum sum of distance that all students should move to form a n×n square. Sample Input2 1682 1011 1271 1052 900 0Sample Output41Problem I. SearchlightsDescriptionThere is a piece of grids land of size n×m. Chandler and his team take responsibility to guard it. There are some searchlights on some pieces and each of them has a capability to lighten a distance towards four directions: north, south, east and west. Different searchlight has different lightening capability shown in levels. Searchlight with level k means that it can lighten k grids (including the gird that the searchlight stands in) along any of the four directions. Shown in following figure, there is a searchlight of level 3 and the shadow grids are ones that can be lightened by it. Particularly, searchlight of level 1 means that it can only lighten the grid in which the searchlight stands.Figure: A searchlight of Level 3Each searchlight has a maximum level. You can decrease a searchlight’s level to save the energy. A searchlight whose maximum level is k can be turned to level k, k-1, k-2, …, 1 and 0. Level 0 means turning off the searchlight.A grid is well-guarded if and only if at least one of the following two conditions is satisfied:1.There is a searchlight in this grid, and it is not switched to level 0 (the light is on).2.The grid is lightened by at least two searchlights. One lightens it in horizontaldirection (east or west), and another lightens it in vertical direction (north or south).Chandler asks you to help finding a solution that he can turn on some of the searchlights so that:1.All the grids are well-guarded.2.All the searchlights turned on are in a same level.3.That same level mentioned above is as small as possible.More specifically, if you choose a same level Q, then all the searchlights whose maximum level are less than Q have to be turned off. Please help him to find a solution with the minimum same level.InputThe input file contains several test cases.For each test case, the first line is two integers n and m, representing a grids land of size n×m. (0<n<=100, 0<m<=10000). Following n lines describe an n×m matrix in which a i,j means the maximum level of the searchlight in grid (i, j). a i,j can be zero, which means there is no searchlight on that grid. For all the cases, a i, j<=10000.The input file ends with a line containing two zeros.OutputFor each test case, output a single line with an integer, representing the minimum level you have found. If there is no such a solution, output “NO ANSWER!”Sampl e Input2 20 23 02 20 21 00 0Sampl e Output2NO ANSWER!Problem J. Infinite monkey theorem DescriptionCould you imaging a monkey writing computer programs? Surely monkeys are smart among animals. But their limited intelligence is no match for our human beings. However, there is a theorem about monkeys, and it states that monkeys can write everything if given enough time.The theorem is called “Infinite monkey theorem”. It states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type any given text, which of course includes the programs you are about to write (All computer programs can be represented as text, right?).It’s very easy to prove this theorem. A little calculation will show you that if the monkey types for an infinite length of time the probability that the output contains a given text will approach 100%.However, the time used is too long to be physically reasonable. The monkey will not be able to produce any useful programs even if it types until the death of the universe. To verify this and ensure that our human beings are not replaceable by monkeys, you are to calculate the probability that a monkey will get things right.InputThere will be several test cases.Each test case begins with a line containing two integers n and m separated by a whitespace (2<=n<=26, 1<=m<=1000). n is the number of keys on the typewriter and the monkey will hit these keys m times. Thus the typewriter will finally produce an output of m characters.The following n lines describe keys on the typewriter. Each line has a lower case letter and a real number separated by a whitespace. The letter indicates what the typewriter will produce if the monkey hits that key and the real number indicates the probability that the monkey will hit this key. Two hits of the monkey are independent of each other (Two different hits have the same probability for a same key), and sum of all the probabilities for each key is ensured to be 1.The last line of the test case contains a word composed of lower case letters. The length of the word will be less than or equal to 10.The input will end with a line of two zeros separated by a whitespace. This line should not be processed.OutputFor each test case, output one line containing the probability that the given word will appear in the typewriter’s output. The output should be in percentage format and numbers should be rounded to two digits after the decimal point.Sampl e Input4 10w 0.25o 0.25r 0.25d 0.25word2 10a 1.0b 0.0abc2 100a 0.312345b 0.687655abab0 0Sampl e Output2.73%0.00%98.54%。
ACM--ICPC竞赛简介

对参赛选手的意义
对学校的意义
对于参赛选手:
开展国际大学生程序设计竞赛(ICPC)活动有 利于优秀人才脱颖而出 国际顶尖IT企业争要中大在ACM竞赛中取得优 异成绩的同学 各方面能力得到全面提升,包括自学能力、编程 能力、沟通协作能力、心理承受能力等等 就业 考研
近期竞赛
近期竞赛 2010年9月山东省高校ACM竞赛 校内组队(2~3队) 本学期末校内选拔 2010年9-12月区域赛
出
线
各赛区第一名自动出线 其他要等本区域(如亚洲)所有赛区的区域赛 结束再作决定 一般每个赛区出线4-7支队(有重复)
3、2009-2010出线情况
Asia Harbin (4.7/4.43)
National University of Defense Technology – Zoe (China) (1.0) University of Electronic Science and Technology of China – UESTC-CP^2 (China) (0.7) Zhejiang University of Technology – AngryCheers (China) (1.0) South China Agricultural University – SCAUARCTIC (China) (1.0) Hangzhou Dianzi University –HDU – AngelKidd (China) (1.0) (Host 2008)
LOGO
ACM/ICPC竞赛
Contents
1 2 3 4 5 6 7
1、ACM/ICPC简介
2、 竞赛模式 3、往年竞赛情况 4、大赛简要规则 5、校内选拔
ACM_ICPC-1ACM简介与输入输出

2020/11/12
32
优秀竞赛学生回母校做宣传
亲爱的学弟学妹们,你们好!我是来自成都市大 弯中学的廖孜。 古语云,“少不入蜀”。大多指年少的时候停留 在蜀地,往往会使年轻人安于享乐,不思进取、难 成大器。然而,电子科技大学却绝非是这样的。 四年前,我怀着好奇与兴奋的心态进入了电子科 技大学。在奇特的机缘下我接触到了ACM-ICPC 竞赛,并为之奋斗了四年。也正是因此,我有了 一个忙碌却又异常精彩的四年大学生活。我还清 晰记得当时刚入校时许下的种种梦想,亚洲区域 赛金牌,就职Google美国硅谷总部MountainView, 代表中国参加俄罗斯叶卡捷琳堡世界总决赛。尽 管过程曲折,但可贵的是,这些梦想几乎所有都 实现了。不得不感谢电子科技大学这样优秀的大 学,给我梦想提供了舞台。
26
27
28
2020/11/12
29
2020/11/12
30
为什么要参加编程比赛
• 能力的提高 • 学到很多书本上和大学里面学不到的知识和技能 • 有机会云游四海,可以和众多武林高手同场竞技,交到很
多志同道合的朋友
• $$,出国的机会 • 对未来极其有利
– 高考保送、高考加分、保研
– 大公司不仅自己举办、同时自己举办各类编程竞赛、 非常重视选手的编程比赛经历和成绩
2. EOF是一个预定义的常量,等于-1。
例如:
#include <stdio.h> int main(void) {
int a=0,b=0,c=0,k; k=scanf("%d%*d%d",&a,&b,&c); printf("k=%d,a=%d,b=%d,c=%d\n",k,a,b,c); } 若输入:1 2 3,则输出为:k=2,a=1,b=3,c=0 注意: •常常用while(scanf(“…”,…)==…)来判断循环的进行。 •从键盘输入时为表示输入已结束,应该先按Enter,再 Ctrl+Z,再按Enter。
CCF大学生计算机系统与程序设计竞赛

每届大赛设置金、银、铜奖及优秀选手奖。金、银、铜奖的获奖率分别为8%、16%、24%,
获奖证书
其余到场完赛的选手均可获得优秀选手奖。比赛次日的颁奖会现场颁发金、银、铜奖选手的获奖证书并一一 拍照留念,因故未参加颁奖会的铜奖以上选手以及优秀选手奖获得者的获奖证书将在赛后由中国计算机学会邮寄 送达。
每届大赛还将根据各高校得分前三名选手的成绩总和进行高校排名,排名前五名的高校将获得高校排名证书。 组织集体报名的高校的指导老师还将获得指导老师证书。
每道算法题设置十余组测试用例进行黑盒测试,样例难度由易变难,按照通过的测试用例数获得对应的分数。
系统设计与实现题的评分分为正确性得分和性能得分。系统设计与实现题下设若干查询需求,每种查询需求 约有100万个测试用例,按照通过正确的测试用例数获得对应分数,全部测试用例正确将额外获得正确性附加奖 励分。算法题有运行时间限制而系统设计与实现题没有运行时间限制(即不存在因为时间超限不得分的情况), 在某一种查询正确性得分获得满分的基础上,根据全场运行时间最短(性能最好)的程序运行时间与该选手提交 的正确程序的运行时间的比值乘以性能满分值得到该选手的性能分。
赛事报名
参赛资格
报名费用
在当届竞赛前一年内的任意一次(一年共3次)CCF计算机软件能力认证(简称CCF CSP认证)中取得260分 (含)以上的中国高校在校生有资格报名参加该竞赛总决赛。中国计算机学会欢迎各高校组织该校优秀选手集体 报名参赛,也同时允许符合参赛资格的选手以个人名义自费报名参赛。
外界认可
企业认可
高校认可
选手评价
清华大学、北京航空航天大学、国防科技大学、华中科技大学等信息学竞赛传统强校均带队组织现役优秀选 手参加该赛事。清华大学等高校对持有CCF CCSP获奖证书并达到一定水准者,报考计算机及相关专业研究生,享 受机试免试的待遇。
acm

堆(优先队列)
优点:
• 动态维护一组数据中最小(大)的一个 • 实现简单
• 数组维护
<priority_queue>
33
例题: 积水
• 一个长方形网格包含了n*m块地,每块地上面有1个 长方体。每一个长方形盖住了一块地,地的面积是1 平方英寸。相邻的地上的长方体之间没有空隙。一场 大雨降临了这个建筑物,在建筑物的某些区域有积水 产生。 • 给各方格高度, 求积水总量
12
网络资源
• • http://acm.timus.ru • http://acm.sgu.ru • /usacogate • • /bbs/index.php
是多少?
39
• 字符串: • 方法一: 折叠法:即把所有字符的ASCII码加起来 • 方法二:ELFhash函数
int ELFhash( char* key ) { unsigned int h = 0; while( *key ){ h = ( h << 4 ) + *key++; unsigned long g = h & 0Xf0000000L; if ( g ) h ^= g >> 24; h &= -g; } return h % M; }
ACM竞赛 常用算法 &数据结构
浙江大学微ቤተ መጻሕፍቲ ባይዱ技术俱乐部 彭鹏
1
1、ACM/ICPC简介
2、竞赛中常见的16种题型 3、时空复杂度的分析 4、竞赛中基本的数据结构与算法 5、ZOJ入门
2
ACM/ICPC简介
• ACM
– Association for Computing Machinery
ACM程序设计竞赛例题[1]
![ACM程序设计竞赛例题[1]](https://img.taocdn.com/s3/m/8e8360ed84868762cbaed565.png)
A C M程序设计竞赛例题[1]-CAL-FENGHAI.-(YICAI)-Company One1备战ACM资料习题1.0-1背包问题在0 / 1背包问题中,需对容量为c 的背包进行装载。
从n 个物品中选取装入背包的物品,每件物品i 的重量为wi ,价值为pi 。
对于可行的背包装载,背包中物品的总重量不能超过背包的容量,最佳装载是指所装入的物品价值最高。
程序如下:#include <>void readdata();void search(int);void checkmax();void printresult();int c=35, n=10; ");printf("\n");}printf("\n");}6.素数环问题把从1到20这20个数摆成一个环,要求相邻的两个数的和是一个素数。
分析:用回溯算法,考察所有可能的排列。
程序如下:#include <>#include <>void search(int);void init(); 表示空格;’X’表示墙。
程序如下:#include <>#include <>void search(int,int);int canplace(int,int);void readdata(); Floodfill给一个20×20的迷宫和一个起点坐标,用广度优先搜索填充所有的可到达的格子。
提示:参考第2题。
2. 电子老鼠闯迷宫如下图12×12方格图,找出一条自入口(2,9)到出口(11,8)的最短路本题给出完整的程序和一组测试数据。
状态:老鼠所在的行、列。
程序如下:#include<>void readdata();a[i][j]=0; ....注:测试数据可在运行时粘贴上去(点击窗口最左上角按钮,在菜单中选则“编辑”/“粘贴”即可)。
从ACM-ICPC探索提升大学生程序设计能力的方法

从ACM/ICPC探索提升大学生程序设计能力的方法摘要 acm/icpc是世界各国大学生最具影响力的国际计算机类的赛事,是广大爱好计算机编程的大学生展示才华的舞台,是各个大学计算机教育成果的直接体现。
本文提出在指导学生参加acm/icpc 的日常的教学过程和集训过程中积累的一些提升大学生程序设计能力的教学经验和方法,和同行们探讨。
关键词 acm/ icpc;程序设计;课程设置;实战集训中图分类号tp39 文献标识码a 文章编号1674-6708(2010)26-0228-021 acm/icpc介绍acm/icpc (acm international collegiate programming contest,国际大学生程序设计竞赛)是由国际计算机界历史悠久、颇具权威性的组织acm(association for computing machinery,国际计算机协会)主办的。
是世界上公认的规模最大、水平最高的国际大学生程序设计竞赛。
其目的旨在使大学生运用计算机来充分展示自己分析问题和解决问题的能力。
竞赛从1970年至今已举办了34届,受到国际各知名大学的普遍重视,并受到全世界各著名计算机公司的高度关注。
acm/icpc已成为世界各国大学生最具影响力的国际计算机类的赛事,是广大爱好计算机编程的大学生展示才华的舞台,是各个大学计算机教育成果的直接体现。
该项竞赛分为区域预赛和国际决赛两个阶段进行,各预赛区第一名自动获得参加世界决赛的资格,世界决赛安排在每年的3月~4月举行,而区域预赛安排在上一年的9月~12月在各大洲举行。
竞赛中每队3人仅拥有一台计算机,要求选手在全封闭的环境内(可以携带包括词典在内的任何纸质的资料,但不得有电子资料)连续五个小时进行解答,而且对程序的时间复杂度和空间复杂度有一定的要求。
竞赛用英文命题,题目数量在6~10题之间,试题没有规定范围,涉及知识面非常广。
这就要求参赛学生不仅具有扎实的程序设计能力、良好的数学功底和数学建模能力,还要有较强的团队协作能力和压力下程序设计能力。
icpc知识点

icpc知识点一、概述ICPC(国际大学生程序设计竞赛)是全球范围内最著名的大学生计算机竞赛之一。
参加ICPC的选手需要具备扎实的计算机基础知识和编程能力,熟悉ICPC的知识点对于取得好成绩至关重要。
本文将全面、详细、完整地探讨ICPC的知识点,帮助读者了解ICPC竞赛的要求和考察内容。
二、数据结构1. 数组•数组是一种线性数据结构,可以存储多个相同类型的元素。
•数组的访问和修改时间复杂度为O(1),插入和删除的时间复杂度为O(n)。
•在ICPC竞赛中,数组常用于存储和处理一组数据,如存储图的邻接矩阵等。
2. 链表•链表是一种动态数据结构,通过指针相连的方式存储数据。
•链表的访问和修改时间复杂度为O(n),插入和删除的时间复杂度为O(1)。
•在ICPC竞赛中,链表常用于实现队列、栈等数据结构,以及解决一些特定的问题。
3. 栈和队列•栈是一种后进先出(LIFO)的数据结构,只能在一端进行插入和删除操作。
•队列是一种先进先出(FIFO)的数据结构,可以在一端进行插入,在另一端进行删除操作。
•在ICPC竞赛中,栈和队列常用于解决与括号匹配、表达式求值等相关的问题。
4. 树和二叉树•树是一种非线性的数据结构,由若干个节点组成,节点之间存在层次关系。
•二叉树是一种特殊的树结构,每个节点最多有两个子节点。
•在ICPC竞赛中,树和二叉树常用于解决与搜索、遍历、动态规划等相关的问题。
三、算法1. 排序算法•冒泡排序:通过相邻元素的比较和交换来实现排序,时间复杂度为O(n^2)。
•快速排序:通过选择一个基准元素,将数组划分为两部分,然后递归地对子数组进行排序,时间复杂度为O(nlogn)。
•归并排序:将数组分成两个子数组,分别进行排序,然后合并两个有序子数组,时间复杂度为O(nlogn)。
•在ICPC竞赛中,排序算法常用于解决与查找、去重、贪心等相关的问题。
2. 图算法•图是一种非线性的数据结构,由节点和边组成,用于表示对象之间的关系。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
国际大学生程序设计竞赛试题与分析(一)
郭嵩山;崔吴
【期刊名称】《现代计算机:上半月版》
【年(卷),期】2000(000)085
【总页数】5页(P89-93)
【作者】郭嵩山;崔吴
【作者单位】中山大学信息科学与技术学院计算机科学系;中山大学信息科学与技术学院计算机科学系
【正文语种】中文
【中图分类】TP311
【相关文献】
1.推动世界大学生程序设计竞赛(ACM/ICPC)在中国的发展——《世界大学生程序设计竞赛(ACM/ICPC)高级教程》建设实践 [J], 秦绪好;孟欣
2.国际大学生程序设计竞赛试题与算法分析(三):动态规划… [J], 郭嵩山;陈明睿
3.国际大学生程序设计竞赛试题与分析(四):动态规划及其… [J], 谢剑辉;郭嵩山
4.国际大学生程序设计竞赛试题与算法分析(二) 回溯算法 [J], 郭嵩山;吴汉荣
5.北京师范大学大学生在第38届ACM国际大学生程序设计竞赛全球总决赛中取得好成绩 [J], 肖希
因版权原因,仅展示原文概要,查看原文内容请购买。