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. MQTT 客户端应用及常见问题(C#)

    https://blog.csdn.net/dengyaan/article/details/51752327 最近因为工作需要,需要使用C# 语言编写一个通过MQTT协议 ,上传数据到云端的工具.因 ...

  2. https://lug.ustc.edu.cn/wiki/user/boj/linkers-and-loaders

    https://lug.ustc.edu.cn/wiki/user/boj/linkers-and-loaders   程序员的自我修养——链接.装载与库

  3. Tosca :配置环境参数

    # 跟Modules TestCases并列 ,右键创建 #再右键创建配置(结构自己安排) #再创建配置参数 #使用配置参数 #引用配置的环境参数

  4. vim 显示行号 临时&永久

    设置vim 永久显示行号 - electrocrazy的博客 - CSDN博客https://blog.csdn.net/electrocrazy/article/details/79035216 v ...

  5. VUE导入Excel

    import FilenameOption from './components/FilenameOption' import AutoWidthOption from './components/A ...

  6. 小D课堂 - 零基础入门SpringBoot2.X到实战_第9节 SpringBoot2.x整合Redis实战_40、Redis工具类封装讲解和实战

    笔记 4.Redis工具类封装讲解和实战     简介:高效开发方式 Redis工具类封装讲解和实战         1.常用客户端 https://redisdesktop.com/download ...

  7. [原][osg][OSGEARTH]OE的关闭打开自动计算裁剪面被OE的海洋ocean影响

    在osgEarthUtil 下 Ocean.cpp 的  traverse函数中: // we don't want the ocean participating in the N/F calcul ...

  8. Closing the Sim-to-Real Loop: Adapting Simulation Randomization with Real World Experience

    Closing the Sim-to-Real Loop: Adapting Simulation Randomization with Real World Experience 模拟到实际循环闭环 ...

  9. Qt编写气体安全管理系统13-短信告警

    一.前言 短信告警这个模块在很多项目中都用上了,比如之前做过的安防系统,温湿度报警系统等,主要的流程就是收到数据判断属于某种报警后,组织短信字符串内容,发送到指定的多个手机号码上面,使用的是短信猫硬件 ...

  10. AD域 域管理员常用命令

    简介: 暂时我需要管理60台终端计算机,但是分布的比较广泛,在我们单位整个场区零零散散的分布,巡检一圈仅步行时间就超过30分钟. 为了更好的管理终端计算机,现在正在实验性的配置域,用域来管理这些计算机 ...