A.前n-10个有8即合法。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
char s[N];
int T,n; int main(){
for (scanf("%d",&T); T--; ){
scanf("%d%s",&n,s+); bool flag=;
rep(i,,n-+) if (s[i]==''){ flag=; break; }
if (flag) puts("YES"); else puts("NO");
}
return ;
}

B.这6个数两两乘积不同,于是有多种方法。

(1) (1,1) (2,2) (3,4) (3,5)

(2) (1,2) (3,4) (1,3) (1,5)

(3) (1,2) (2,3) (4,5) (5,6)

(方法三能做7个数的情况)

下面写的是方法一,因为判的情况没写全导致场上FST。

 #include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
int x,y,a[N],b[N]; bool ok(int i){ return i== || i== || i== || i== || i== || i==; } int main(){
puts("? 1 1"); fflush(stdout); scanf("%d",&a[]); a[]=sqrt(a[]);
puts("? 2 2"); fflush(stdout); scanf("%d",&a[]); a[]=sqrt(a[]);
puts("? 3 4"); fflush(stdout); scanf("%d",&x);
puts("? 3 5"); fflush(stdout); scanf("%d",&y);
rep(i,,) if (ok(i) && (x%i==) && (y%i==) && ok(x/i) && ok(y/i)){
rep(j,,) b[j]=;
b[a[]]++; b[a[]]++; b[i]++; b[x/i]++; b[y/i]++; b[+++++-a[]-a[]-i-x/i-y/i]++;
bool flag=;
rep(j,,) if (ok(j) && b[j]!=){ flag=; break; }
if (flag) continue;
printf("! %d %d %d %d %d %d\n",a[],a[],i,x/i,y/i,+++++-a[]-a[]-i-x/i-y/i); break;
}
return ;
}

C.并查集

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
int n,m,k,fa[N],sz[N],a[N]; int get(int x){ return fa[x]==x ? x : fa[x]=get(fa[x]); } int main(){
scanf("%d%d",&n,&m);
rep(i,,n) fa[i]=i,sz[i]=;
rep(i,,m){
scanf("%d",&k);
rep(j,,k) scanf("%d",&a[j]);
rep(j,,k-) if (get(a[j])!=get(a[j+])) sz[get(a[j+])]+=sz[get(a[j])],fa[get(a[j])]=get(a[j+]);
}
rep(i,,n) printf("%d ",sz[get(i)]);
return ;
}

D.贪心

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
int n,x,y,mx,b[N];
char s[N]; int main(){
scanf("%d%s",&n,s+);
rep(i,,n){
if (s[i]=='('){ if (x<=y) x++,b[i]=; else y++,b[i]=; }
else{ if (x<=y) y--,b[i]=; else x--,b[i]=; }
}
rep(i,,n) printf("%d",b[i]);
return ;
}

E.找到最大的l是的[1,l]的所有数加入序列后都是有序的,同样找到最小的r满足[r,m]的所有数都相对有序,然后two-pointers统计答案即可,细节很多比较难写。

F.对每个数a[i]求它的贡献,也即它在所有包含它的区间中的排名之和。从小到大加数,考虑每个已加的数在多少个区间中对它产生1的贡献,树状数组直接维护即可。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=,mod=1e9+;
int n,m,i,j,a[N],id[N],c1[N],c2[N],ans; bool cmp(int x,int y){ return a[x]<a[y]; }
void inc(int&x,int v){ x+=v; if(x>=mod)x-=mod; }
void add(int c[N],int x,int v){ while (x<=n) inc(c[x],v),x+=x&-x; }
int que(int c[N],int x,int res=){ while (x) inc(res,c[x]),x-=x&-x; return res; } int main(){
scanf("%d",&n);
rep(i,,n) scanf("%d",&a[i]),id[i]=i;
sort(id+,id+n+,cmp);
rep(i,,n){
add(c1,id[i],id[i]);
ans=(ans+1ll*a[id[i]]*(1ll*(n-id[i]+)*que(c1,id[i])%mod+1ll*id[i]*que(c2,n-id[i]+)%mod)%mod)%mod;
add(c2,n-id[i]+,n-id[i]+);
}
printf("%d\n",ans);
return ;
}

Educational Codeforces Round 65 (Div. 2)的更多相关文章

  1. Educational Codeforces Round 65 (Rated for Div. 2)题解

    Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...

  2. Educational Codeforces Round 84 (Div. 2)

    Educational Codeforces Round 84 (Div. 2) 读题读题读题+脑筋急转弯 = =. A. Sum of Odd Integers 奇奇为奇,奇偶为偶,所以n,k奇偶性 ...

  3. Educational Codeforces Round 65 (Rated for Div. 2) D. Bicolored RBS

    链接:https://codeforces.com/contest/1167/problem/D 题意: A string is called bracket sequence if it does ...

  4. Educational Codeforces Round 65 (Rated for Div. 2) C. News Distribution

    链接:https://codeforces.com/contest/1167/problem/C 题意: In some social network, there are nn users comm ...

  5. Educational Codeforces Round 65 (Rated for Div. 2) B. Lost Numbers

    链接:https://codeforces.com/contest/1167/problem/B 题意: This is an interactive problem. Remember to flu ...

  6. Educational Codeforces Round 65 (Rated for Div. 2) A. Telephone Number

    链接:https://codeforces.com/contest/1167/problem/A 题意: A telephone number is a sequence of exactly 11  ...

  7. Educational Codeforces Round 65 (Rated for Div. 2)B. Lost Numbers(交互)

    This is an interactive problem. Remember to flush your output while communicating with the testing p ...

  8. [ Educational Codeforces Round 65 (Rated for Div. 2)][二分]

    https://codeforc.es/contest/1167/problem/E E. Range Deleting time limit per test 2 seconds memory li ...

  9. Educational Codeforces Round 65 (Rated for Div. 2)

    A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 ...

随机推荐

  1. Android系统Audio框架介绍【转】

    本文转载自:https://blog.csdn.net/yangwen123/article/details/39502689 音频基础知识声音有哪些重要属性呢? 响度(Loudness)响度就是人类 ...

  2. Flink 之 Data Source

    Data Sources 是什么呢?就字面意思其实就可以知道:数据来源. Flink 做为一款流式计算框架,它可用来做批处理,即处理静态的数据集.历史的数据集: 也可以用来做流处理,即实时的处理些实时 ...

  3. 8款超好用的SVG编辑工具用起来

    随着响应式网页的发展,对于内容呈现的要求也越来越高,尤其是图像.为了在各种设备上能实现自然伸缩或扩展而不影响图片质量,所以矢量图形(SVG)正变得越来越受欢迎. 大家都知道,在计算机图形学中,有两种主 ...

  4. python socketpool:通用连接池(转)

    简介 在软件开发中经常要管理各种“连接”资源,通常我们会使用对应的连接池来管理,比如mysql数据库连接可以用sqlalchemy中的池来管理,thrift连接可以通过thriftpool管理,red ...

  5. UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: invalid continuation byte

    需求:python如何实现普通用户登录服务器后切换到root用户再执行命令 解决参考: 代码: def verification_ssh(host,username,password,port,roo ...

  6. Java开发手册-编程规约精选

    # Java开发手册-编程规约精选 ## 总约 - 采用驼峰写法 ## 变量 - 首字母小写 ## 方法 - 方法名首字母小写- 参数首字母小写 ## 引用 - <阿里巴巴Java开发手册> ...

  7. Windows 操作系统 快捷键

    窗口放大缩小:  + ↑↓ 最小化窗口: ALT + Esc 关闭窗口: Alt + F4 搜索功能:  + 直接输入搜索内容 打开文件管理器:  + E 在文件管理器中切换: Tab

  8. Dart泛型

    /* 通俗理解:泛型就是解决 类 接口 方法的复用性.以及对不特定数据类型的支持(类型校验) */ //只能返回string类型的数据 // String getData(String value){ ...

  9. Spark ML 中 VectorIndexer, StringIndexer等用法(转载)

    VectorIndexer 主要作用:提高决策树或随机森林等ML方法的分类效果.VectorIndexer是对数据集特征向量中的类别(离散值)特征(index categorical features ...

  10. osg坐标位置转换

    osg::Vec3f vec3f1 = hookNode->getBound().center(); osg::NodePathList nodePAthList1 = hookNode-> ...