A. Road to Cinema很明显满足二分性质的题目。题意:某人在起点处,到终点的距离为s。 汽车租赁公司提供n中车型,每种车型有属性ci(租车费用),vi(油箱容量)。 车子有两种前进方式 :①. 慢速:1km消耗1L汽油,花费2分钟。 ②.快速:1km消耗2L汽油,花费1分钟。 路上有k个加油站,加油不需要花费时间,且直接给油箱加满。 问在t分钟内到达终点的最小花费是多少?(租车子的费用) 若无法到达终点,输出-1不谈二分的写法.. 我们...
George is a cat, so he loves playing very much.Vitaly put n cards in a row in front of George. Each card has one integer written on it. All cards had distinct numbers written on them. Let’s number the cards from the left to the right with integers from 1 to n. Then the i-th card from the left contains number pi (1?≤?pi?≤?n).Vitaly wants the row to have exactly k cards left. He also wants the i-...
传送门终于学会多项式开根了哈哈……反正题解都烂大街了,我就不写了,直接贴代码算了……(犯懒ing) 1/**************************************************************2 Problem: 36253 User: _Angel_4 Language: C++5 Result: Accepted6 Time:29048 ms7 Memory:5944 kb8****************************************************************/ 9 #include<cstdio>
10 #include<cstring>
11 #include<algorithm>
...
include <bits/stdc++.h>using namespace std;
int n;
int x[200005], y[200005], xr[200005];
int main() {
int t;
cin >> t;
while(t--) {
cin >> n;
for(int i = 1; i <= n; i++) cin >> x[i];
for(int i = 1; i <= n; i++) {
int tmp = 0;
if(i == 1) {
y[1] = 0;
xr[1] = 0 ^ x[1];
continue;
}
int fuck = 0;
for(int j = 0; j < 32; j++) {//逐位分析
fuck |= (((xr[i - 1] >> j) & 1) << j);
if((xr[i - 1] >> j) & 1) {//...
题目链接:https://codeforces.com/contest/1265/problem/C题意从大到小给出 $n$ 只队伍的过题数,要颁发 $g$ 枚金牌,$s$ 枚银牌,$b$ 枚铜牌,要求:$g < s, g < b$$g + s + d \le \lfloor \frac{n}{2} \rfloor$金牌队伍的过题数大于银牌,银牌队伍的过题数大于铜牌输出颁发奖牌数最多的一种方案。题解根据第三个要求,奖牌一定是按过题数的大小颁发的。金牌只颁发给过题最多数的队伍,可以使 $g < s, g < b$ 最容易满足。接下来...
先上代码,采用php脚本语言
<?php/* * Copyright (C) FatHong*//* 数据初始化,weight: 权重 */
$hosts[a] = array(weight => 5, current_weight => 0, count => 0);
$hosts[b] = array(weight => 3, current_weight => 0, count => 0);
$hosts[c] = array(weight => 2, current_weight => 0, count => 0);$result = array();/* 模拟10次 */
for ($i = 0; $i < 10; $i++) {round_robin($hosts, $result);
}/* 输出结果 */
print_r(...
pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))
#define rson(x) ((x<<1)|1)
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 3e5+5;
priority_queue<pii,vector<pii>,greater<pii>>a;
i...
LIS定义:
LIS(Longest Increasing Subsequence)最长上升子序列
一个数的序列bi,当b1 < b2 < … < bS的时候,我们称这个序列是上升的。
对于给定的一个序列(a1, a2, …, aN),我们可以得到一些上升的子序列(ai1, ai2, …, aiK),
这里1 <= i1 < i2 < … < iK <= N。
比如,对于序列(1,5,3,4,8),有它的一些上升子序列,如(1, 8), (3, 4, 8)等等。
这些子序列中最长的长度是4,比如子序列(1, 3, 4, 8).
你的任务,就是对于给定...
This is the hard version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task.
You are given a string ss, consisting of lowercase English letters. Find the longest string, tt, which satisfies the following conditions:The length of tt does not exceed the length of ss.
tt is a pa...
Phoenix has n blocks of height h1,h2,…,hn, and all hi dont exceed some value x. He plans to stack all
To satisfy his love of matching socks, Phoenix has brought his n socks (n is even) to the sock store. Each of his socks has a color ci and is either a left sock or right sock.
Phoenix can pay one dollar to the sock store to either:recolor a sock to any color c′ (1≤c′≤n)
turn a left sock into a right sock
turn a right sock into a left sockThe sock store may perform each of these changes any num...
题意:刚开始有一长度为\(n\),空白的空数组,有\(q\)次询问,每次询问都会选一个区间\([l,r]\)将其全部涂成颜色i,现在给你一个数组,问你能否得到所给的数组,\(0\)表示任何颜色都可以.题解:首先这题有一个坑点,数组中必须要有颜色\(q\),然后,易知两个相同颜色之间一定不能有比它小的颜色出现,那么对于\(0\)我们就很容易构造了,如果数组中没有颜色\(q\),就先让一个\(0\)变成\(q\),其他情况只要正反递推让\(0\)等于相邻位置的颜色就好了,...