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. NPVariant -js传递给NPAPI插件参数在firefox和chrome需要采用不同的获取方式

    原帖地址:http://blog.sina.com.cn/s/blog_4c6631790102wd1o.html 整数参数 typedef struct _NPVariant { NPVariant ...

  2. 解决request.getSession().getServletContext().getRealPath("/")为null问题

    今天把程序部署到服务器,发现异常,FileNotFound异常,很快定位到getServletContext().getRealPath("/");返回空的问题.这个问题通常是传递 ...

  3. Java 中如何输入

    import java.util.Scanner; //键盘扫描类public class Test{public static void main(String[] args) {Scanner i ...

  4. web常用服务架构

    架构风格就是一种项目的设计模式.常见的架构风格有基于客户端与服务端的.基于组件模型的(EJB).分层架构(MVC).面向服务架构(SOA)等. 一.单体架构 单体架构也称为单体系统或单体应用,就是一种 ...

  5. ArcMap与快捷键冲突

    ArcMap与快捷键冲突 商务合作,科技咨询,版权转让:向日葵,135-4855__4328,xiexiaokui#qq.com 问题:armap进入鼠标自动导航状态,arcmap失控,系统紊乱,导致 ...

  6. Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas

    Arthas 用户文档 — Arthas 3.1.0 文档https://alibaba.github.io/arthas/ alibaba/arthas: Alibaba Java Diagnost ...

  7. python制作简单excel统计报表1之with的简单用法

    # coding=utf-8 def open_file(): """使用with打开一个文件""" # 普通操作文件方法 # f = op ...

  8. pycharm怎么修改python路径

    今天安装Django的时候遇到了python版本冲突,找不到python路径,所以又重新安装了一个python3.6.5 安装完之后,突然发现自己的pycharm是之前Anaconda的3.5版本,那 ...

  9. Windows下MariaDB数据库安装图文教程

    MariaDB是基于MySQL的开源数据库,兼容MySQL,现有的MySQL数据库可以迁移到MariaDB中使用   说明: MariaDB是基于MySQL的开源数据库,兼容MySQL,现有的MySQ ...

  10. 【Java】 rapid-generator 代码生成器

    rapid-generator是一个生成器引擎,让你可以专注与代码生成器模板的编写, 可以生成如ibatis,ibatis3,hibernate,spring_mvc,struts2等等代码. rap ...