题目链接:http://codeforces.com/problemset/problem/500/A 题目意思:给出 n-1 个 cell,每个 cell 有一个值 ai,表示在这个编号为 i 的 cell,能到达i + ai 的cell,但不能反过来,即从 i+ai 到达 i 这个 cell.问从第一个cell 开始,是否可以到达 t 这个cell. 第一次过不了pretest 是因为没有考虑到,如果 t = 1的情况,后来被人 hack 之后就不知道原因了...原来是因为第 n 个 cel…
题意:给出n个数,终点t 从第i点能够跳到i+a[i],问能否到达终点 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include<set> #include<queue> #include<algor…
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <sstream> #include <set> #include <map> #include <queue>…
http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开始,如果可以完成任务,那么输出id总和,否则输出-1. 思路:简单的模拟,注意如果不能完成任务,那么ser数组是不能更新的. #include <cstdio> #include <algorithm> #include <iostream> #include <cs…
A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have eq…
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed…
Description On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible nu…
洛谷 Codeforces bzoj1,bzoj2 这可真是一道n倍经验题呢-- 思路 我首先想到了DP,然后矩阵,然后线段树,然后T飞-- 搜了题解之后发现是模拟费用流. 直接维护选k个子段时的最优解似乎也可以做,然而复杂度是O(nk2logn),显然跑不过. 考虑一种费用流做法.序列里每个点拆成入点和出点,源连入汇连出,入点和出点间连流量1费用ai的边,相邻点出点向入点连流量1费用0的边,整体限流k. 直接跑当然还不如暴力.观察一下这个做法是在干啥:每次选择费用最大的一段,然后利用反向边将这…
题目链接:https://codeforces.com/contest/1090/problem/B Examplesstandard input The most famous characters of Pushkin’s works are Onegin \cite{onegin}, Dubrovsky \cite{dubrovsky} and Tsar Saltan \cite{saltan}. \begin{thebibliography}{99} \bibitem{saltan} A…
http://codeforces.com/problemset/problem/586/C 题意:1~n个孩子排成一排看病.有这么一个模型:孩子听到前面的哭声自信心就会减弱:第i个孩子看病时会发出v[i]的叫声,他后面的那个人的自信心(不是p[i+1])会减少v[i],再后面一个会减少v[i]-1,如此下去直到声音减弱为0.若某个人的自信心小于0,则他哭着跑回家,他身后的所有人会减掉d[i] 的自信. 题解:直接模拟很困难,有一个想法是将逃跑的孩子的声音和将他吓跑的(正在接诊的)声音叠加成s,…
B. Mishka and trip time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she cho…
原题链接:http://codeforces.com/problemset/problem/583/A 题意: 很迷很迷,表示没看懂..但是你看样例就秒懂了 题解: 照着样例模拟就好 代码: #include<iostream> #include<cstring> #include<algorithm> #define MAX_N 55 using namespace std; bool h[MAX_N],v[MAX_N]; int n; int main(){ cin…
Zane the wizard is going to perform a magic show shuffling the cups. There are n cups, numbered from 1 to n, placed along the x-axis on a table that has m holes on it. More precisely, cup i is on the table at the position x = i. The problematic bone…
Wilbur and Array Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initially consisting of n zeros. At one step, he c…
题目链接 (BZOJ) https://www.lydsy.com/JudgeOnline/problem.php?id=3836 (Codeforces) http://codeforces.com/contest/280/problem/D 题解 似乎是最广为人知的模拟费用流题目. 线段树维护DP可以做,但是合并的复杂度是\(O(k^2)\), 会TLE. 考虑做\(k\)次费用流,很容易建出一个图,中间的边容量都是1,求的是最大费用. 做费用流的过程,我们每次找一条最长路,然后将其增广,增…
Codeforces 题面传送门 & 洛谷题面传送门 提供一个模拟网络流的题解. 首先我们觉得这题一脸可以流的样子,稍微想想可以想到如下建图模型: 建立源点 \(S,T\) 和上下两排点,不妨设上排点为 \(x_1,x_2,\cdots,x_n\),下排点为 \(y_1,y_2,\cdots,y_n\). 对于每个 \(i\) 我们连一条 \(S\to x_i\),容量为 \(b_i\) 的边,表示每个基站最多提供 \(b_i\) 个网络服务. 对于每个 \(i\),我们连边 \(x_i\to…
给出烟花的爆炸方式和爆炸次数 问最后有多少个格子会被炸到 如果dfs的话会超时... 利用模拟每一层来搜索..? 思想就是一开始有一个爆炸点向上 然后模拟完第一段 会产生一个爆炸点 朝两个方向 就用vector来存 每一层都处理一段的爆炸点 产生新一段的爆炸点 因为5*30=150 所以图建300就可以了 300 * 300 * 30的时间复杂度 但是常数很大..不过无所谓啦.. 需要注意的是 一个爆炸点可能会同时出现两次朝同一个方向开始爆炸的烟花 这个是没有意义的 所以拿一个数组来记录 不然最…
Guess a number! Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the sho…
题意:给定一个n*m的矩阵,都是01矩阵,然后每次一个询问,改变一个格的值,然后问你最大有数是多少. 析:就是按他说的模拟,要预处理,只要把每行的最大值记下来,当改变时,再更新这一行的最大值. 代码如下: #include<bits/stdc++.h> using namespace std; const int maxn = 500 + 5; int a[maxn][maxn]; int num[maxn]; int main(){ int n, m, q, x, y; while(cin…
题意: n个小朋友去拔牙 每个小朋友在拔牙的时候会哭 哭声是vi分贝 距离门口vi远的小朋友听到了哭声会害怕 他们的勇气值p会减少d 如果勇气值p小于等于零 他们就会在门外哭并立即离开拔牙队列(回家找妈妈……) 这个哭声门外所有的小朋友都能听到 所以这个哭声会同时减少所有小朋友的勇气值 问最后有多少小朋友可以拔完牙 思路: 就是模拟一下这个过程 好像后面的小朋友哭了对前面的小朋友没有影响 WA了一次是因为结构体里没用long long…… #include<stdio.h> #include&…
比较简单的模拟,建议使用STL优先队列. 代码如下: #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; #define N 1000010 ]; int outn[N]; priority_queue<int,vector<int>,greater<int> >que; int main()…
893A Chess For Three 思路: 直接模拟即可,第一盘永远是A与B开始 代码: #include <bits/stdc++.h> using namespace std; #define _for(i,a,b) for(int i=(a); i<(b); ++i) #define _rep(i,a,b) for(int i=(a); i<=(b); ++i) int n,num,a[4]; int main() { ios::sync_with_stdio(fals…
D. Vladik and Favorite Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could…
Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row. The beauty of the arrangement is the le…
A. Buses Between Cities time limit per test: 1 second memory  limit per test: 256 megabytes input: standard input output: standard output Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11…
http://codeforces.com/problemset/problem/158/B B. Taxi time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output After the lessons n groups of schoolchildren went outside and decided to visit Polyca…
Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special - it starts on the top floor, can only move down, and has infinite capacity. Fl…
Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from 11 to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways…
写这道题题解的目的就是纪念一下半个小时才读懂题...英文一多读一读就溜号... 读题时还时要静下心来... 题目链接: http://codeforces.com/contest/659/problem/B 题意: 给定地区及来自相应地区的人的分数,每个地区选两个分数最高的人 参加区域赛,如果选出的两个人唯一,则输出名字,否则如果还需要进行下一次比赛,输出"?". 分析: 不唯一的情况就是第二个人和第三个人的分数相同嘛...排个序找一下就好了. 代码: #include <bit…
题目链接: A:Ostap and Grasshopper B:Urbanization C:Tennis Championship D:Taxes 分析:这场第一二题模拟,三四题数学题 A. 直接模拟即可 B. 排序从大到小取n1个数到城市1,n2个数到城市二,n1<=n2 C. 递推.斐波拉契数列 dp[i] 表示赢i场比赛需要多少人, 则 dp[0] = 1,dp[1] = 2,dp[3] = dp[1] +dp[0],  dp[ans] = dp[ans-1] + dp[ans-2]一次…