Codeforces Global Round 4 题解
技不如人,肝败吓疯……
开场差点被 A 题意杀了,幸好仔细再仔细看,终于在第 7 分钟过掉了。
跟榜。wtf 怎么一群人跳题/倒序开题?
立刻紧张,把 BC 迅速切掉,翻到了 100+。
开 D。感觉有点吓人……感觉有点可做?
的确挺可做。再切掉 D,但是此时已经到 300+ 了。
没事,还能翻。
开 E。这……什么玩意?
瞄了一眼 F1,……
盯着这两题盯到自闭。
最后 rk 1000 左右。我的名字颜色真的是对的吗……
A
看懂题了就是水题。选上所有小于等于第一个党派一半人数的党派,如果不行就不行,否则就可以。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=,f=;
while(ch<'' || ch>'') f|=ch=='-',ch=getchar();
while(ch>='' && ch<='') x=x*+ch-'',ch=getchar();
return f?-x:x;
}
int n,a[maxn],s,s2,cnt;
int main(){
n=read();
FOR(i,,n) s+=a[i]=read();
s2=a[];cnt=;
FOR(i,,n) if(a[]>=*a[i]) s2+=a[i],cnt++;
if(s2*<=s) puts("");
else{
printf("%d\n",cnt);
printf("1 ");
FOR(i,,n) if(a[]>=*a[i]) printf("%d ",i);
}
}
B
枚举中间的 o,然后看看两边能选出多少个 vv,简单前缀/后缀和解决。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=,f=;
while(ch<'' || ch>'') f|=ch=='-',ch=getchar();
while(ch>='' && ch<='') x=x*+ch-'',ch=getchar();
return f?-x:x;
}
int n,pre[maxn],suf[maxn];
ll ans;
char s[maxn];
int main(){
scanf("%s",s+);
n=strlen(s+);
FOR(i,,n){
pre[i]=pre[i-];
if(s[i]=='v' && s[i-]=='v') pre[i]++;
}
ROF(i,n-,){
suf[i]=suf[i+];
if(s[i]=='v' && s[i+]=='v') suf[i]++;
}
FOR(i,,n) if(s[i]=='o') ans+=1ll*pre[i-]*suf[i+];
cout<<ans<<endl;
}
C
最左上角的可以随便选。
第一行的在左边那个已经确定后,可以发现可以选两种。
第一列的同理,每个可以选两种。
不在第一行也不在第一列的,发现只能选固定的一种。
答案就是 $2^{n+m}$。
(为什么一群人盯样例盯出来了……)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=,mod=;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=,f=;
while(ch<'' || ch>'') f|=ch=='-',ch=getchar();
while(ch>='' && ch<='') x=x*+ch-'',ch=getchar();
return f?-x:x;
}
int n,m;
int qpow(int a,int b){
int ans=;
for(;b;b>>=,a=1ll*a*a%mod) if(b&) ans=1ll*ans*a%mod;
return ans;
}
int main(){
n=read();m=read();
printf("%d\n",qpow(,n+m));
}
D
每个点度数不小于 $2$,所以边数最小为 $n$。
不妨找到第一个大于等于 $n$ 的质数作为边数。
根据一些%*#(!^定理(猜想?),$n\ge 3$ 时,$[n,\frac{3}{2}n]$ 中至少有一个质数。
可以通过下面这个方法构造出一个有 $2n-m$ 个度数为 $2$ 的点,$m-n$ 个度数为 $3$ 的点的图。
首先 $i$ 向 $i+1$ 连边($n$ 向 $1$ 连边),此时用了 $n$ 条边,所有点度数为 $2$。
剩下的 $m-n$ 条边随便连,只要没有重边并且这 $m-n$ 条边不重复用点就好了。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=,f=;
while(ch<'' || ch>'') f|=ch=='-',ch=getchar();
while(ch>='' && ch<='') x=x*+ch-'',ch=getchar();
return f?-x:x;
}
int n,m,cnt;
bool use[maxn];
bool check(int x){
if(x==) return false;
for(int i=;i*i<=x;i++) if(x%i==) return false;
return true;
}
int main(){
n=m=read();
while(!check(m)) m++;
cnt=m-n;
printf("%d\n",m);
FOR(i,,n){
printf("%d %d\n",i,i%n+);
if(cnt && !use[i]){
int to=i%n+;
to=to%n+;
while(use[to]) to=to%n+;
use[i]=use[to]=true;
printf("%d %d\n",i,to);
cnt--;
}
}
}
E
这也太神了吧……
对于长度 $\le 3$ 的字符串,可以任意选其中一个字符。
对于长度 $\ge 4$ 的字符串,取出前两个字符和后两个字符,由于相邻字符不相等,所以一定可以从前两个中选出一个,后两个中选出一个,使得它们相等。删掉这四个字符,然后重复操作。
可以发现这样求出的一定是回文串而且合法。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=,f=;
while(ch<'' || ch>'') f|=ch=='-',ch=getchar();
while(ch>='' && ch<='') x=x*+ch-'',ch=getchar();
return f?-x:x;
}
int n,m,l,r;
char s[maxn],t[maxn];
int main(){
scanf("%s",s+);
n=strlen(s+);
l=;r=n;
while(r-l+>=){
if(s[l]==s[r] || s[l]==s[r-]) t[++m]=s[l];
else t[++m]=s[l+];
l+=;r-=;
}
FOR(i,,m) putchar(t[i]);
if(l<=r) t[++m]=s[l];
ROF(i,m,) putchar(t[i]);
}
F1/F2
Codeforces Global Round 4 题解的更多相关文章
- Codeforces Global Round 2 题解
Codeforces Global Round 2 题目链接:https://codeforces.com/contest/1119 A. Ilya and a Colorful Walk 题意: 给 ...
- Codeforces Global Round 3 题解
这场比赛让我上橙了. 前三题都是大水题,不说了. 第四题有点难想,即使想到了也不能保证是对的.(所以说下面D的做法可能是错的) E的难度是 $2300$,但是感觉很简单啊???说好的歪果仁擅长构造的呢 ...
- Codeforces Global Round 16题解
E. Buds Re-hanging 对于这个题该开始还是没想法的,但这显然是个思维题,还是要多多动手推样例,实践一下. 简化题意:给定一个有根树,规定某个点为树干,当且仅当这个点不是根,且这个点至少 ...
- Codeforces Global Round 1 (A-E题解)
Codeforces Global Round 1 题目链接:https://codeforces.com/contest/1110 A. Parity 题意: 给出{ak},b,k,判断a1*b^( ...
- Codeforces Global Round 11 个人题解(B题)
Codeforces Global Round 11 1427A. Avoiding Zero 题目链接:click here 待补 1427B. Chess Cheater 题目链接:click h ...
- CodeForces Global Round 1
CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...
- Codeforces Global Round 1 - D. Jongmah(动态规划)
Problem Codeforces Global Round 1 - D. Jongmah Time Limit: 3000 mSec Problem Description Input Out ...
- Codeforces Global Round1 简要题解
Codeforces Global Round 1 A 模拟即可 # include <bits/stdc++.h> using namespace std; typedef long l ...
- Codeforces Global Round 1 (CF1110) (未完结,只有 A-F)
Codeforces Global Round 1 (CF1110) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...
随机推荐
- 【django json.dumps 报错】 datetime.datetime is not JSON serializable
django 中,json.dumps 无法直接转译 datetime 类型的值. 找了无数方法,找到一个最优.最简洁的解决办法: json.dumps(results, indent=4, sort ...
- JeeSite | 数据权限应用
中午吃饭时看了一下陆毅版的<三国>,刚好看的是蜀军缺粮,诸葛亮让王平去劫司马懿的粮.司马懿看蜀军用木牛流马运量很方便,就抢了蜀军的木牛流马仿制了一批,结果司马懿用它运粮时,被王平冒充司马懿 ...
- var和let区别简述
因为习惯用var声明变量,以至于ES6出了let来替代var,我依然继续用var,直到后来慢慢了解let之后,开始尝试使用 不同点: ①:var属于ES5规范,let属于ES6规范 ②: ...
- LCM Walk HDU - 5584
A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. No ...
- 2019-11-26-C#-判断方法是否被子类重写
原文:2019-11-26-C#-判断方法是否被子类重写 title author date CreateTime categories C# 判断方法是否被子类重写 lindexi 2019-11- ...
- PHP json中文
json_encode 和 json_decode 只支持utf-8编码的字符串,GBK的字符串要用json就得转换成utf-8字符串 看效果 <?php header("Conten ...
- AI人脸识别的测试重点
最常见的 AI应用就是人脸识别,因此这篇文章从人脸识别的架构和核心上,来讲讲测试的重点. 测试之前需要先了解人脸识别的整个流程,红色标识代表的是对应AI架构中的各个阶段 首先是人脸采集. 安装拍照摄像 ...
- 去除数组空格 php
public function trimArray($params){ if (!is_array($params)) return trim($params); return array_map([ ...
- EM算法直观认识
Expectation Maximization, 字面翻译为, "最大期望". 我个人其实一直都不太理解EM算法, 从我个人的渊源来看, 之前数理统计里面的参数估计, 也是没有太 ...
- Linux 初识Libevent网络库
初识Libevent libevent是用c写的高并发网络io库,只要有文件描述符,就都可使用libevent. libevent使用回调函数(callback) . 有了libevent,网络编程我 ...