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) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...
随机推荐
- git push 报504 (因提交文件内容过大而失败的解决方案)
Enumerating objects: 60, done. Counting objects: 100% (60/60), done. Delta compression using up to 4 ...
- vue项目打包之后样式错乱问题,如何处理
最近公司做的这个项目,要大量修改element里面的css样式,所以项目打包之后 会出现样式和本地开发的时候样式有很多不一样,原因可能是css加载顺序有问题,样式被覆改了. 所以在mian.js里面这 ...
- WEB测试应该注意哪些地方,怎样才能做好WEB测试
基于Web的系统测试与传统的软件测试既有相同之处,也有不同的地方,对软件测试提出了新的挑战.基于Web的系统测试不但需要检查和验证是否按照设计的要求运行,而且还要评价系统在不同用户的浏览器端的显示是否 ...
- Singnal R 练习参考
项目地址:https://gitee.com/dhclly/IceDog.SignalR/tree/master/src/chat demo的实现均来自官方的教程,教程地址: ASP.NET Core ...
- 个性化你的 Git Log 的输出格式
个性化你的 Git Log 的输出格式
- 车位iou计算
车位检测中,判断多帧图像检测出的车位是否是同一个车位.计算其IOU. 判断一个点是否在一个四边形内 Approach : Let the coordinates of four corners be ...
- FastDFS图片服务器(分布式文件系统)学习。
参考:https://blog.csdn.net/hiqingtian/article/details/79413471 https://blog.csdn.net/sinat_40399893/ar ...
- 排序算法Java代码实现(二)—— 冒泡排序
本篇内容: 冒泡排序 冒泡排序 算法思想: 冒泡排序的原理是:从左到右,相邻元素进行比较. 每次比较一轮,就会找到序列中最大的一个或最小的一个.这个数就会从序列的最右边冒出来. 代码实现: /** * ...
- QT4.8.7和VS2010环境搭建及使用
(一)环境搭建 首先下载QT4.8.7的安装包.QT Addin 1.11插件和VS2010安装包.第一步:安装好VS2010第二步:安装QT4.8.7(qt-opensource-windows-x ...
- Java foreach循环
foreach循环:增强性的for循环应用: 在for语句中,需要使用索引来进行操作具体的数组或集合内容操作:而foreach可以取消索引的操作细节: for ( 类型 变量 : 数组 | 集合 ) ...