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) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...
随机推荐
- 大话设计模式Python实现-外观模式
外观模式(Facade Pattern):为子系统中的一组接口提供一个一致界面,此模式定义一个高层接口,使得子系统更加容易使用 下面是一个外观模式的demo: #!/usr/bin/env pytho ...
- C#中文转换为拼音NPinyin代码【转】
项目地址:https://code.google.com/p/npinyin/ 在一个采集的程序中,为了给每个文章起一个别名,据说有很好的别名的话,对于百度.google的收录 是很有好处的.按照Se ...
- java架构之路-(nginx使用详解)nginx的反向代理和优化配置
书接上回说,nginx我们学会了简单的配置.那么我今天来聊一下,我们ngxin的一些优化配置(我不是很懂,不敢谈高级配置).我先来看一下nginx的好处和正向代理. nginx的好处 1.可以高并发连 ...
- Windows cmd 和 PowerShell 中文乱码问题解决
临时方案: 在命令行下输入:chcp 65001 长期方案: 要修改注册表,自己网上搜吧
- VMware——安装CentOS
VMware——安装CentOS 摘要:本文主要记录了在VMware虚拟机里安装CentOS的步骤. 下载操作系统 可以从下面的镜像地址去下载各种版本的CentOS,此次安装使用的版本是7.2: ht ...
- vue中输入框只能输入数字
方案1:增加自定义指令 自定义指令写法: directives: { numberOnly: { bind(el) { ...
- xcodeinstruments 内存检测
http://blog.csdn.net/totogo2010/article/details/8233565
- Struts2 运行流程
Struts2运行流程 1.在web.xml中使用Struts的核心过滤器拦截所有请求. <filter> <filter-name>struts2</filter-na ...
- C# 测试网络速度例子
using System.Net.NetworkInformation; namespace PingExample { public partial class Form1 : Form { pub ...
- 数据库MySQL学习笔记高级篇
数据库MySQL学习笔记高级篇 写在前面 学习链接:数据库 MySQL 视频教程全集 1. mysql的架构介绍 mysql简介 概述 高级Mysql 完整的mysql优化需要很深的功底,大公司甚至有 ...