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) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...
随机推荐
- tensor 中mul_,add_解读
pytorch 中文网文档链接 https://ptorch.com/docs/1/Tensor 每一个张量tensor都有一个相应的torch.Storage保存其数据,张量类提供了一个多维的,横向 ...
- 【UOJ#390】【UNR#3】百鸽笼(动态规划,容斥)
[UOJ#390][UNR#3]百鸽笼(动态规划,容斥) 题面 UOJ 题解 发现这就是题解里说的:"火山喷发概率问题"(大雾 考虑如果是暴力的话,你需要记录下当前每一个位置的鸽笼 ...
- 关于@HtmlHelper帮助器参数
@Html.ActionLink("首页", "Index", "Index", new{},new { @class = "na ...
- Windows cmd 和 PowerShell 中文乱码问题解决
临时方案: 在命令行下输入:chcp 65001 长期方案: 要修改注册表,自己网上搜吧
- Java内功心法,深入解析面向对象
什么是对象 对象是系统中用来描述客观事物的一个实体,它是构成系统的一个基本单位.一个对象由一组属性和对这组属性进行操作的一组服务组成. 类的实例化可生成对象,一个对象的生命周期包括三个阶段:生成.使用 ...
- head中的base标签:设置超链接的默认行为
默认情况下,如果不指定超链接的target属性,则在当前窗口打开.使用head中的base可以制定超链接的base类,一切超链接都会继承它的属性. <html> <head> ...
- CSS animation属性
定义和用法 animation属性是下列属性的一个缩写属性: animation-name animation-duration animation-timing-function animation ...
- 关于Qt 静态成员函数调用信号
class globalCalcThread; extern globalCalcThread *g_calcThread; class globalCalcThread : public QThre ...
- 让你的项目使用Ts吧
推荐在这里阅读 9012年都过半了,还不会用ts你就out了 why ? 三大框架angular2以后的版本完全是用ts开发的, vue对ts的支持也越来越好, React也有TSX组件 还在犹豫什么 ...
- Redis入门学习(二):下载安装
Linux操作系统 Download, extract and compile Redis with: $ wget http://download.redis.io/releases/redis-4 ...