题目链接:The 18th Zhejiang University Programming Contest Sponsored by TuSimple - G Traffic Light 题解: 题意自己翻译,此题首先肯定是要广搜的,不过要开一个1e5*1e5的数组好像有点困难, 所以用结构体来存每个点的下标,然后从源点开始广搜.定义一个pair<node,int>,第一个存节点信息,第二个存到当前节点的步数,因为还要处理到达每个节点的状态. 状态:走奇数步并且状态为1与走偶数步状态为0的结果…
模拟题,用链表来进行模拟 # include <stdio.h> # include <stdlib.h> typedef struct node { int num; struct node *q; struct node *h; }node; struct Node { node *start; node *end; int sum; }m[]; int main() { int k; scanf("%d", &k); while (k--) { i…
题意: 第一类物品的价值为k1,第二类物品价值为k2,背包的体积是 c ,第一类物品有n 个,每个体积为S11,S12,S13,S14.....S1n ; 第二类物品有 m 个,每个体积为 S21,S22,S23,S24.......S2m; 每次装入物品时,得到的价值是 剩余背包体积*该类物品的价值:问最多能得到的总价值是多少. 思路: 要想得到最大的总价值,肯定要从小的开始装,然后分别枚举第一类,第二类装进去的最大体积,还有将两类回合装入背包的最大体积,得到最后的答案 我们用dp[i][j]…
题意:模拟栈,正常pop,push,多一个merge A B 形象地说就是就是将栈B堆到栈A上. 题解:直接用list 的pop_back,push_back,splice 模拟, 坑:用splice,第一次超时,正要大改 发现是cin超时... #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<vector> #include<cstring> #include<set> #includ…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5738 题意 给你一个map 每个格子里有一个红绿灯,用0,1表示状态.当所在格子为0时只能上下移动,为1时左右移动.人一秒动一次,并且每一秒必须移动,灯每秒改变依次状态.问从起点到终点最短时间. 题解:   就看成一道墙壁会按时间周期改变的走迷宫. 只是墙壁的作用是限制走的方向而不是不能通过. 关于如何判定迷宫无法走通,按套路设了一个vis数组,试了一发就ac了…
题目链接 题意: 题意简单,就是一个简单的数据结构,对栈的模拟操作,可用链表实现,也可以用C++的模板类来实现,但是要注意不能用cin cout,卡时间!!! 代码: #include <stdio.h> #include <iostream> #include <vector> #include <deque> #include <list> #define IO ios::sync_with_stdio(0);\ cin.tie();cout…
Pretty Matrix Time Limit: 1 Second      Memory Limit: 65536 KB DreamGrid's birthday is coming. As his best friend, BaoBao is going to prepare a gift for him. As we all know, BaoBao has a lot of matrices. This time he picks an integer matrix with  row…
传送门 题意: 给出了三个新定义: E-prime : ∀ num ∈ E,不存在两个偶数a,b,使得 num=a*b;(简言之,num的一对因子不能全为偶数) E-prime factorization : 定义集合P由 E-prime 元素组成,定义 e = p1*p2*.....*pn:(p1,p2,....,pn ∈ P , |P| = n) E-factorial : 定义 e!! = 2*4*6*8*.........*e:(简言之,偶数e及其之前的偶数连乘积) 输出一个数 e ,求…
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=391 A     Thanks, TuSimple! Time Limit: 1 Second      Memory Limit: 65536 KB 题意:有t组数据,n个男生,m个女生,每个人身高不同,每个人都期望和比自己高或者比自己低的人跳舞,问最多有多少对舞伴 题解:把期待比自己高的男生身高和期待比自己低的男生身高分别存在两个数组a[n],b[n]里,同…
Knuth-Morris-Pratt Algorithm Time Limit: 1 Second      Memory Limit: 65536 KB In computer science, the Knuth-Morris-Pratt string searching algorithm (or KMP algorithm) searches for occurrences of a "word" W within a main "text string"…
Marjar Cola Time Limit: 1 Second      Memory Limit: 65536 KB Marjar Cola is on sale now! In order to attract more customers, Edward, the boss of Marjar Company, decides to launch a promotion: If a customer returns x empty cola bottles or y cola bottl…
Handshakes Time Limit: 2 Seconds      Memory Limit: 65536 KB Last week, n students participated in the annual programming contest of Marjar University. Students are labeled from 1 to n. They came to the competition area one by one, one after another…
Doki Doki Literature Club Time Limit: 1 Second      Memory Limit: 65536 KB Doki Doki Literature Club! is a visual novel developed by Team Salvato. The protagonist is invited by his childhood friend, Sayori, to join their high school's literature club…
我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错误也可以是MLE,而且我的内存就是卡了那么一点点,在比赛紧张的状态下人也变傻了吧. 这次的题目难度是两边到中间一次递增的,但是我也不懂榜怎么会那样  A Peak Time Limit: 1 Second      Memory Limit: 65536 KB A sequence of  inte…
a  ZOJ 3860 求和大家不一样的那个数,签到,map水之 #include<cstdio> #include<map> using namespace std; map<int,int> mp; int main(){ int t,n,x; while(~scanf("%d",&t)){ while(t--){ scanf("%d",&n); mp.clear(); while(n--){ scanf(&q…
Seven Segment Display Time Limit: 1 Second      Memory Limit: 65536 KB A seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix d…
一个有几个小坑的bfs 题目很长,但并不复杂,大概总结起来有这么点. 有t组输入 每组输入n, m, p.表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为起点,'$'为终点,'.'为通路,'*'为不通. 问从起点到终点最少需要多久? 一眼看去,裸的bfs嘛,10*10的地图,简单! 不过还是连错4次…… 注意! 每一秒有4种操作,注意,不是三种,1. 光标左移,2. 光标右移,3. 按照光标方向行走,4. 不动(尤其是这一个). 所谓光标左移,右移,…
Princess Cjb is caught by Heltion again! Her knights Little Sub and Little Potato are going to Heltion Kingdom to rescue her. Heltion Kingdom is composed of islands, numbered from to . There are bridges in the kingdom, among which the -th bridge conn…
感想: 今天三个人的状态比昨天计院校赛的状态要好很多,然而三个人都慢热体质导致签到题wa了很多发.最后虽然跟大家题数一样(6题),然而输在罚时. 只能说,水题还是刷得少,看到签到都没灵感实在不应该. 题目链接:http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=391 A:简单贪心,按高度sort一下就好了,这里用优先队列处理 #include <cstdio> #include <queue> #i…
#include <iostream> #include <algorithm> using namespace std; ; int a[maxn]; int main(){ int t; cin >> t; while(t--){ int n; cin >> n; string s; cin >> s; ; bool l = true; int i; ;i >= ;i -= ){ sum += *i+; if(l){ '){ a[i]…
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=392 E:Sequence in the Pocket 思路:从后往前判断在不在应该在的位置,如果不在则需要放到最前面,通过cnt控制当前的数 比较 排好序的数组的数. code: #include<bits/stdc++.h> using namespace std; #define LL long long #define INF 2000000000 #…
Heap Partition Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge A sequence S = {s1, s2, ..., sn} is called heapable if there exists a binary tree T with n nodes such that every node is labelled with exactly one element from the se…
What Kind of Friends Are You? Time Limit: 1 Second      Memory Limit: 65536 KB Japari Park is a large zoo home to extant species, endangered species, extinct species, cryptids and some legendary creatures. Due to a mysterious substance known as Sands…
Lucky 7 Time Limit: 1 Second      Memory Limit: 65536 KB BaoBao has just found a positive integer sequence  of length  from his left pocket and another positive integer  from his right pocket. As number 7 is BaoBao's favorite number, he considers a p…
CONTINUE...? Time Limit: 1 Second      Memory Limit: 65536 KB      Special Judge DreamGrid has  classmates numbered from  to . Some of them are boys and the others are girls. Each classmate has some gems, and more specifically, the -th classmate has …
King of Karaoke Time Limit: 1 Second      Memory Limit: 65536 KB It's Karaoke time! DreamGrid is performing the song Powder Snow in the game King of Karaoke. The song performed by DreamGrid can be considered as an integer sequence , and the standard…
Peak Time Limit: 1 Second      Memory Limit: 65536 KB A sequence of  integers  is called a peak, if and only if there exists exactly one integer  such that , and  for all , and  for all . Given an integer sequence, please tell us if it's a peak or no…
B题 思路 因为 \[ x=\sum\limits_{k=1}^{n}ka_k\\ y=\sum\limits_{k=1}^{n}ka_{k}^{2} \] 我们设交换前和交换后的这两个等式的值设为\(x_1,y_1,x_2,y_2\),现在我们开始愉快的推公式 \[ \begin{aligned} &x_1-x_2=(i-j)(a_i-a_j)&\\ &y_1-y_2=(i-j)(a_i^2-a_j^2)&\\ \Rightarrow &\frac{y1-y2}{…
河南理工大学第十届校赛 很久没有组队打比赛了,好吧应该说很久没有写题了, 三个人一起玩果然比一个人玩有趣多了... 前100分钟过了4题,中途挂机100分钟也不知道什么原因,可能是因为到饭点太饿了?,最后100分钟一人开一题差点冲到榜首也太刺激了吧! 是一次愉快的游戏体验. 下周去农大参加邀请赛,希望能和今天一样快乐~ 今天是冬至,别忘记吃饺子! 题解和代码 A. Dong Zhi A题地址 题意:输出"Let's eat dumplings",这句话 思路:看标题肯定签到了,但是hp…
传送门 题意: 给出一个序列,你可以将任意一个数移到最前面: 求最少需要移动多少次,可以是此序列变成非递减序列: 思路: 定义 (ai,aj) 为逆序对 ( i < j , ai > aj ), 求出 aj 的最大值,用变量 curMax 存储: 遍历一遍数组,求解 ans: 对于∀ i ∈[1,n] ①如果 ai < curMax , ans++; ②如果 ai == curMax , 那么需要特殊判断: (2.1)如果 ai 之前不曾出现比 curMax 大的数,不需要移动: (2.…