【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 -- 开机启动无界面后台程序

    简单的说,这是一个没有界面的后台运行的应用程序 而且,还有一功能:开机自启动,启动运行一个服务 程序结构非常简单,两个类,一个是service的扩展类,一个是BroadcastReceiver扩展类 ...

  2. 启动eclipse时出现“Failed to load the JNI shared library jvm.dll”错误及解决-及eclipse版本查看

    启动eclipse时出现“Failed to load the JNI shared library jvm.dll”错误及解决-及eclipse版本查看 学习了:https://www.cnblog ...

  3. c# Dictionary拓展2个key得到1个value

    using System.Collections.Generic; using System.Collections; Dictionary<Tuple<int, int>, int ...

  4. C#使用CurrentUICulture切换语言

    1. 创建2个窗口   2. 窗口1属性Localizable设置为True,Language选择英语(美国) 然后把窗口1中控件的Text由中文编辑成英文,Form2一样设置.   此时,Form1 ...

  5. php-fpm.conf配置说明(重点要改动和优化的地方)

    <?xml version="1.0" ?> <configuration> All relative paths in this config are r ...

  6. android实例讲解----Tomcat部署Web应用方法总结

      参考文档:http://blog.csdn.net/yangxueyong/article/details/6130065  Tomcat部署Web应用方法总结             一.架构介 ...

  7. 兔子--html,js,php,ASP,ASP.NET,JSP的关系

    html是超文本链接语言.是静态的.显示在client.仅仅用HTML做出来的网页是静态网页.没不论什么交互功能. JS是一种基于对象和事件驱动的脚本语言,执行在client.是一种比較简单的编程语言 ...

  8. DDR 布线规则

    https://blog.csdn.net/cpf099/article/details/52038862 https://blog.csdn.net/cpf099/article/details/5 ...

  9. vue-导入静态文件

    vue导入静态文件不用像网上说的那么麻烦,其实跟普通Django项目导入类似,vue项目中有一个static文件,将你的静态文件放入到里面,然后引入就好 导入的时候和普通Django程序类似:↓ &l ...

  10. kubernetes调度之pod优先级和资源抢占

    系列目录 Pod可以拥有优先级.优先意味着相对于其它pod某个pod更为重要.如果重要的pod不能被调度,则kubernetes调度器会优先于(驱离)低优先级的pod来让处于pending状态的高优先 ...