【A:暴力】

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int a[maxn],vis[maxn],N,M;
int main()
{
scanf("%d%d",&N,&M);
for(int i=;i<=M;i++){
scanf("%d",&a[i]);
vis[a[i]]=;
}
for(int i=;i<=N;i++)
if(!vis[i]) printf("%d\n",i);
return ;
}

【B:模拟】

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
vector<short int>G[maxn];
int main()
{
int N,M,x,i,j;
scanf("%d%d",&N,&M);
for(i=;i<=N;i++)
for(j=;j<M;j++){
scanf("%d",&x); G[i].push_back(x);
}
printf("%d %d\n",M,N);
for(i=;i<M;i++){
for(j=;j<=N;j++) printf("%d ",G[j][i]);
printf("\n");
}
return ;
}

【C:数位DP入门题】

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=;
int N,L,a[maxn];
ll dp[maxn][][maxn],num[maxn][][maxn],ans;
void divede()
{
while(N){ a[++L]=N%; N/=; }
}
ll dfs(int pos,int lim,int x)
{
if(pos==){ num[pos][lim][x]=; return x==;}
if(!lim&&dp[pos][lim][x]) return dp[pos][lim][x];
int ups=lim?a[pos]:;
for(int i=;i<=ups;i++){
dp[pos][lim][x]+=(dfs(pos-,lim&(i==ups),i))+(x==?num[pos-][lim&(i==ups)][i]:);
num[pos][lim][x]+=num[pos-][lim&(i==ups)][i];
}
return dp[pos][lim][x];
}
int main()
{
scanf("%d",&N);
divede();
for(int i=;i<=a[L];i++) ans+=dfs(L-,i==a[L],i);
printf("%lld\n",ans);
return ;
}

【D:单调队列】

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=;
const int inf=1e9+;
int a[maxn],L1[maxn],b[maxn],R1[maxn],L2[maxn],R2[maxn],q[maxn],head;
vector<int>G[maxn];
ll get(int u)
{
int Len=G[b[u]].size(); ll res=;
for(int i=;i<Len;i++){
if(u>=G[b[u]][i]){
ll r=min(R1[G[b[u]][i]],R2[u])-u+;
ll l=G[b[u]][i]-max(L2[u],L1[G[b[u]][i]])+;
if(r>&&l>) res+=l*r;
}
else {
ll r=min(R2[u],R1[G[b[u]][i]])-G[b[u]][i]+;
ll l=u-max(L2[u],L1[G[b[u]][i]])+;
if(r>&&l>) res+=l*r;
}
}
return res;
}
int main()
{
int N,i; ll ans=;
scanf("%d",&N);
for(i=;i<=N;i++) scanf("%d",&a[i]);
for(i=;i<=N;i++) scanf("%d",&b[i]);
a[]=inf; head=; q[head]=;
for(i=;i<=N;i++){ //若有相同,只算左边第一个。
while(head&&a[i]>a[q[head]]) head--;
L1[i]=q[head]+; q[++head]=i;
}
a[N+]=inf; head=; q[head]=N+;
for(i=N;i>=;i--){
while(head&&a[i]>=a[q[head]]) head--;
R1[i]=q[head]-; q[++head]=i;
}
for(i=;i<=N;i++) G[a[i]].push_back(i); b[]=inf; head=; q[head]=;
for(i=;i<=N;i++){
while(head&&b[i]>b[q[head]]) head--;
L2[i]=q[head]+; q[++head]=i;
}
b[N+]=inf; head=; q[head]=N+;
for(i=N;i>=;i--){
while(head&&b[i]>=b[q[head]]) head--;
R2[i]=q[head]-; q[++head]=i;
}
for(i=;i<=N;i++) ans+=get(i);
printf("%lld\n",ans);
return ;
}

【CQ18高一暑假前挑战赛5】标程的更多相关文章

  1. 【CQ18高一暑假前挑战赛4】标程

    [二分或者STL] 二分: #include<bits/stdc++.h> using namespace std; ; int a[maxn]; int main() { ,pos; s ...

  2. 【CQ18高一暑假前挑战赛3.5】标程

    [A:快速幂相关] #include<bits/stdc++.h> using namespace std; int qpow(int a,int x){ a%=;; while(x){ ...

  3. 【CQ18高一暑假前挑战赛3】标程

    [A:LCM] #include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll a,b, ...

  4. 【CQ18高一暑假前挑战赛2】标程

    [昨晚打校赛,5个小时打完很累了,所以搞忘出题了...对不起学弟们,不过出的题都亲自写过一遍,可以保证题目和代码长度都不长,题目难度不大] [A:bush博弈] #include<bits/st ...

  5. 【CQ18高一暑假前挑战赛1】标程

    [A] #include<bits/stdc++.h> using namespace std; #define ll long long ll qpow(ll a,ll x,ll Mod ...

  6. [转]关于一些SPFA的标程

    SPFA算法 求单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm. 最短路径快速算法-SPFA算法是西南交通大学段凡丁于1994年发表的. 适用范围:给定 ...

  7. [求助][SPOJ MARIOGAM]-高斯消元(内含标程,数据等)

    小蒟蒻开始做概率的题之后,遇到了这道题,然而,他发现自己的程序调试了无数次也无法通过,系统总是返回令人伤心的WA, 于是,他决定把这一天半的时间收集到的资料放在网上, 寻求大家的帮助, 也可以节省后来 ...

  8. hdu6435 Problem J. CSGO标程讲解以及改正标程的一个错误(本来第一个样例过不了2333) 以及 poj2926 五维曼哈顿距离模板

    比赛的时候抄poj2926的模板,但改不来啊orz #include <iostream> #include <cstdio> #include <cstring> ...

  9. 暑假前的flag

    暑假到了,为了简便新开了一个博客,供暑假刷体放一些题解,玩acm1年多了,cf还是蓝名,真是菜的一笔,明年就大三了,马上就要毕业了,然而还是啥也不会,兼职和智障没什么两样,当初大一吹的牛逼说要成为学校 ...

随机推荐

  1. android状态栏总结

    针对状态栏的操作,只针对4.4kitKat(含)以上的机型,部分国产rom会失效,目前发现的有华为的EMUI Activity必须是noActionbar主题 本文基于StatusBarUtils略作 ...

  2. win10任务管理器开机老是自己打开

    win10任务管理器开机老是自己打开 学习了:https://zhidao.baidu.com/question/332868722086816045.html 还没有注意过这个东西:系统失败-> ...

  3. log4net报错Could not load type 'System.Security.Claims.ClaimsIdentity'

    使用log4net,在win7上可以正常使用,但是在部分xp电脑上可以生成access数据库,但是无法写数据到mdb 排除了程序原因,怀疑是xp缺少什么dll之类的 偶然查到log4net的调试方法: ...

  4. Laravel 设置语言不生效的问题

    使用了validate 验证,提示错误默认是 英文的.将en 改为zh-CN 后 运行 composer require "overtrue/laravel-lang:~3.0"时 ...

  5. Linux退出时出现there are stopped jobs如何解决?

    Linux 使用exit时出现there are stopped jobs如何解决? 这是因为一些命令被挂起了, 在后台驻留,需要关闭. 解决问题: 输入命令jobs -l显示停止进程的详细列表 可以 ...

  6. shell(2):正则表达式

    一.整理正则表达式博客 (1)正则 正则就是用一些具有特殊含义的符号组合到一起(称为正则表达式)来描述字符或者字符串的方法.或者说:正则就是用来描述一类事物的规则. 在linux中,通配符是由shel ...

  7. (updated on Mar 1th)Programming Mobile Applications for Android Handheld Systems by Dr. Adam Porter

    本作品由Man_华创作,采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可.基于http://www.cnblogs.com/manhua/上的作品创作. Lab - Inte ...

  8. LVDS、MIPI、EDP、VGA、DVI、HDMI、DP3.0(雷电接口)

    1.LVDS 2.mipi 3.EDP:Embedded DisplayPort 4.VGA VGA接口的特性: 1)理论上能够支持2048x1536分辨率画面传输. 2)VGA由于是模拟信号传输,所 ...

  9. A20 Gate信号

    https://doc.docsou.com/ba8e6b0612d6a989b7cebeaae-5.html Gate A20 Option 功能:设置A20 地址线的控制模式 设定值:Fast 或 ...

  10. Django-models-m2m

    在Django的orm中,如果有多对多的字段,那么他的第三张表时自己生成的,参考官方文档发现第三张表可以自己写↓: 而且第三张表好像是可以自定制的 from django.db import mode ...