打挺差的。

不过\(C,D\)一眼秒了,大概是对这几个月努力的一个结果?

\(B\)玄学错误挂了两发。

脑子痛然后打到一半就去睡觉了。

————————————————————————————————————————————————

以上是闲话部分。

\(A\)

考虑判断是否存在一个前缀和不满足条件。

有后缀的话拉一个过来交换就行,否则就是没有方案。

A
// code by fhq_treap
#include<bits/stdc++.h>
#define ll long long
#define N 300005 inline ll read(){
char C=getchar();
ll A=0 , F=1;
while(('0' > C || C > '9') && (C != '-')) C=getchar();
if(C == '-') F=-1 , C=getchar();
while('0' <= C && C <= '9') A=(A << 1)+(A << 3)+(C - 48) , C=getchar();
return A*F;
} struct P{
int to,next;
}; struct Map{
P e[N << 1];
int head[N],cnt;
Map(){
std::memset(head,0,sizeof(head));
cnt = 0;
}
inline void add(int x,int y){
e[++cnt].to = y;
e[cnt].next = head[x];
head[x] = cnt;
}
}; ll t;
ll num[N];
ll n,k; int main(){
t = read();
while(t -- ){
n = read(),k = read();
ll sum = 0,s = 0;
for(int i = 1;i <= n;++i)
num[i] = read(),s += num[i];
if(s == k)
puts("NO");
else{
puts("YES");
for(int i = 1;i <= n;++i){
sum += num[i];
if(sum == k){
std::cout<<num[i + 1]<<" "<<num[i]<<" ";
++i;
}
else
std::cout<<num[i]<<" ";
}
puts("");
}
}
}

\(B\)

考虑基本单位是一个边长为\(1\)或\(sqrt(2)\)的单位正方形。

判断是否能有这样平方数个单位正方形。

玄学错误挂了两发,重写一下就过了,怪离谱的

B
// code by fhq_treap
#include<bits/stdc++.h>
#define ll long long
#define N 300005 inline ll read(){
char C=getchar();
ll A=0 , F=1;
while(('0' > C || C > '9') && (C != '-')) C=getchar();
if(C == '-') F=-1 , C=getchar();
while('0' <= C && C <= '9') A=(A << 1)+(A << 3)+(C - 48) , C=getchar();
return A*F;
} struct P{
int to,next;
}; struct Map{
P e[N << 1];
int head[N],cnt;
Map(){
std::memset(head,0,sizeof(head));
cnt = 0;
}
inline void add(int x,int y){
e[++cnt].to = y;
e[cnt].next = head[x];
head[x] = cnt;
}
}; ll t; int main(){
t = read();
while(t -- ){
ll x = read();
if(x % 2 == 0 && ((int)sqrt(x / 2) * (int)sqrt(x / 2) == x / 2))
puts("YES");
else{
if(x % 4 == 0 && ((int)sqrt(x / 4) * (int)sqrt(x / 4) == x / 4))
puts("YES");
else
puts("NO");
}
}
}

\(C\)

考虑题目的意思就是让这\(m\)组中最小的最大,最大的最小。

那么考虑派完序,一个接一个往这\(m\)组丢,具体实现看代码。

C
// code by fhq_treap
#include<bits/stdc++.h>
#define ll long long
#define N 300005 inline ll read(){
char C=getchar();
ll A=0 , F=1;
while(('0' > C || C > '9') && (C != '-')) C=getchar();
if(C == '-') F=-1 , C=getchar();
while('0' <= C && C <= '9') A=(A << 1)+(A << 3)+(C - 48) , C=getchar();
return A*F;
} struct P{
int to,next;
}; struct Map{
P e[N << 1];
int head[N],cnt;
Map(){
std::memset(head,0,sizeof(head));
cnt = 0;
}
inline void add(int x,int y){
e[++cnt].to = y;
e[cnt].next = head[x];
head[x] = cnt;
}
}; ll t;
ll n,m,k;
ll s[N]; struct T{
ll id,v,to;
}num[N]; bool cmp1(T a,T b){
return a.v < b.v;
} bool cmp2(T a,T b){
return a.id < b.id;
} int main(){
t = read();
while(t -- ){
n = read(),m = read(),k = read();
for(int i = 1;i <= n;++i)
num[i].id = i,num[i].v = read();
std::sort(num + 1,num + n + 1,cmp1);
for(int i = 1;i <= m;++i)
s[i] = 0;
for(int i = 1;i <= n;++i)
s[(i % m) + 1] += num[i].v,num[i].to = (i % m) + 1;
ll minn = 0x3f3f3f3f,maxx = -0x3f3f3f3f;
for(int i = 1;i <= m;++i)
minn = std::min(minn,s[i]),maxx = std::max(maxx,s[i]);
if(maxx - minn <= k){
puts("YES");
std::sort(num + 1,num + n + 1,cmp2);
for(int i = 1;i <= n;++i)
std::cout<<num[i].to<<" ";
puts("");
}
else
puts("NO");
}
}

\(D\)

看出来如果\(l,r\)不相等,则一定要从多的一边向少的一边转变,那么这个时候尽量让能匹配的袜子多就行了。

D
// code by fhq_treap
#include<bits/stdc++.h>
#define ll long long
#define N 300005 inline ll read(){
char C=getchar();
ll A=0 , F=1;
while(('0' > C || C > '9') && (C != '-')) C=getchar();
if(C == '-') F=-1 , C=getchar();
while('0' <= C && C <= '9') A=(A << 1)+(A << 3)+(C - 48) , C=getchar();
return A*F;
} struct P{
int to,next;
}; struct Map{
P e[N << 1];
int head[N],cnt;
Map(){
std::memset(head,0,sizeof(head));
cnt = 0;
}
inline void add(int x,int y){
e[++cnt].to = y;
e[cnt].next = head[x];
head[x] = cnt;
}
}; ll t,n,l,r;
ll c[N],lc[N],rc[N],cnt[N];
bool del[N]; int main(){
t = read();
while(t -- ){
n = read(),l = read(),r = read();
for(int i = 1;i <= n;++i)
c[i] = read(),lc[c[i]] = 0,rc[c[i]] = 0,cnt[c[i]] = 0,del[c[i]] = 0;
for(int i = 1;i <= l;++i)
lc[c[i]] ++ ,cnt[c[i]] ++ ;
for(int i = l + 1;i <= n;++i)
rc[c[i]] ++ ,cnt[c[i]] ++ ;
for(int i = 1;i <= l;++i)
if(rc[c[i]])
rc[c[i]] -- ,lc[c[i]] -- ,cnt[c[i]] -= 2;
ll need = abs(r - l) / 2;
if(l > r){
for(int i = 1;i <= l;++i){
while(need && lc[c[i]] >= 2)
lc[c[i]] -= 2,cnt[c[i]] -= 2,need -- ;
}
}else{
if(l < r){
for(int i = l + 1;i <= n;++i)
while(need && rc[c[i]] >= 2)
rc[c[i]] -= 2,cnt[c[i]] -= 2,need -- ;
}
}
ll ans = 0;
for(int i = 1;i <= n;++i){
if(!del[c[i]])
del[c[i]] = 1,ans += cnt[c[i]] ;
}
std::cout<<ans / 2 + abs(r - l) / 2<<std::endl;
}
}

\(E\)

数数题。

大概看出来一点东西。

不过连续的一段的操作自己不会算方案数。

后来补的。

考虑计\(f[i][j]\)为开到\(i\)台,\(j\)台为自己手动开的。

那么就是考虑连续一段(即这一段没有自动开的)的方案数了

长度为\(l\)的一段则必有选择一个\(i\),表示从他开始向两边扩展,则还有\(l - 1\)个位置,有\(i - 1\)个数要丢进去,考虑前\(i - 1\)个数一旦确定,则整个序列确定。

所以连续一段的答案是\(C_{l - 1}^0 + C_{l - 1}^1 ..... = 2^{l - 1}\)

所以\(f[i + k + 1][j + k] = f[i][j] * 2^{k - 1} * C_{j + k}^k\)

E
#include<iostream>
#include<cstdio>
#define ll long long
#define N 500 ll mod;
ll f[N][N];
ll n; inline ll pow(ll a,ll b){
ll ans = 1;
while(b){
if(b & 1)
ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
} ll s[N],inv[N]; inline ll c(ll a,ll b){
return s[a] * inv[a - b] % mod * inv[b] % mod;
} ll ans = 0; int main(){
scanf("%lld%lld",&n,&mod);
s[0] = 1;
for(int i = 1;i <= 405;++i)
s[i] = s[i - 1] * i % mod;
inv[405] = pow(s[405],mod - 2);
for(int i = 404;i >= 1;--i)
inv[i] = inv[i + 1] * (i + 1) % mod;
for(int i = 1;i <= n;++i)
f[i][i] = pow(2,i - 1);
for(int i = 1;i <= n;++i)
for(int j = 1;j <= i;++j)
for(int k = 1;i + k + 1 <= n;++k)
f[i + k + 1][j + k] = (f[i + k + 1][j + k] + f[i][j] * pow(2,k - 1) % mod * c(j + k,k) % mod) % mod;
for(int i = 1;i <= n;++i)
ans = (f[n][i] + ans) % mod;
std::cout<<ans<<std::endl;
}

\(F\)

果然这题好做很多?

虽然比赛的时候看了一眼就睡了。

后来补的。

很简单的一个构造就是了。

考虑两个点合在一起时把权值和边集都合在一起。

每次挑最大的点和周围一个点合并。

[Codeforces Global Round 14]的更多相关文章

  1. Codeforces Global Round 14 E. Phoenix and Computers

    题目链接 点我跳转 题目大意 给定 \(N\) 台电脑,起初每台电脑都是关闭的 现在你可以随意打开电脑,但如果第 \(i-1\).第 \(i+1\) 台电脑是开启的,则第 \(i\) 台电脑也会自动开 ...

  2. CodeForces Global Round 1

    CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...

  3. Codeforces Global Round 1 - D. Jongmah(动态规划)

    Problem   Codeforces Global Round 1 - D. Jongmah Time Limit: 3000 mSec Problem Description Input Out ...

  4. Codeforces Beta Round #14 (Div. 2)

    Codeforces Beta Round #14 (Div. 2) http://codeforces.com/contest/14 A 找最大最小的行列值即可 #include<bits/s ...

  5. Codeforces Global Round 2 题解

    Codeforces Global Round 2 题目链接:https://codeforces.com/contest/1119 A. Ilya and a Colorful Walk 题意: 给 ...

  6. Codeforces Global Round 1 (A-E题解)

    Codeforces Global Round 1 题目链接:https://codeforces.com/contest/1110 A. Parity 题意: 给出{ak},b,k,判断a1*b^( ...

  7. Codeforces Global Round 3

    Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置 ...

  8. Codeforces Global Round 1 (CF1110) (未完结,只有 A-F)

    Codeforces Global Round 1 (CF1110) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...

  9. 【手抖康复训练1 】Codeforces Global Round 6

    [手抖康复训练1 ]Codeforces Global Round 6 总结:不想复习随意打的一场,比赛开始就是熟悉的N分钟进不去时间,2333,太久没写题的后果就是:A 题手抖过不了样例 B题秒出思 ...

随机推荐

  1. SingleR如何使用自定义的参考集

    在我之前的帖子单细胞分析实录(7): 差异表达分析/细胞类型注释里面,我已经介绍了如何使用SingleR给单细胞数据做注释,当时只讲了SingleR配套的参考集.这次就讲讲如何使用自己定义/找到的基因 ...

  2. 395.至少有 K 个重复字符的最长子串

    题目 给你一个字符串 s 和一个整数 k ,请你找出 s 中的最长子串, 要求该子串中的每一字符出现次数都不少于k .返回这一子串的长度. 示例 1: 输入:s = "aaabb" ...

  3. OO第二单元电梯作业总结

    目录 目录一.第一次作业分析设计策略基于度量分析程序结构二.第二次作业分析设计策略基于度量分析程序结构三.第三次作业分析设计策略基于度量分析程序结构四.分析自己程序的bug五.发现别人程序bug所采用 ...

  4. oo第一单元学习总结

    写在开头: 第一次接触面向对象思想和java语言,在学习以及完成作业的过程经历了一个比较痛苦的过程, 虽然在每次写作业时总是会有一些小小的抱怨,虽然写出的代码还是很差, 但是看到自己有所进步,还是感觉 ...

  5. MySQL 8.0安装 + 配置环境变量 + 连接 cmd

    MySQL 安装教程 搜索 MySQL,进入官网,找到 download 点击适用于 window community 版本,点击图中第二个 450.7 M 的安装包进行下载 这里有五个选项,选择第二 ...

  6. Spring Cloud Gateway + Jwt + Oauth2 实现网关的鉴权操作

    Spring Cloud Gateway + Jwt + Oauth2 实现网关的鉴权操作 一.背景 二.需求 三.前置条件 四.项目结构 五.网关层代码的编写 1.引入jar包 2.自定义授权管理器 ...

  7. 常用JAVA API :HashSet 和 TreeSet

    set容器的特点是不包含重复元素,也就是说自动去重. HashSet HashSet基于哈希表实现,无序. add(E e)//如果容器中不包含此元素,则添加. clear()//清空 contain ...

  8. path-sum-ii leetcode C++

    Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given su ...

  9. Java之父 James Gosling 发表博文 《Too Soon》纪念乔布斯。

    几个礼拜前,我们还在讨论乔布斯的辞职.虽然我们都知道这意味着什么,但是我没有想到一切来的如此之快.已经有很多关于这件事情的文章了,特别是"经济学人"的这篇文章. 乔布斯是一个很独特 ...

  10. fork函数详解(附代码)

    虽然篇幅很长,但大多是易懂的代码,不用担心看不完 这里的所有操作,都将在下面的代码中有所体现 fork会拷贝当前进程的内存,并创建一个新的进程.如上图,fork函数会将整个进程的内存镜像拷贝到新的内存 ...