I'm bored with life

水题

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const LL N=1,M=1,MOD=1; int main()
{//freopen("t.txt","r",stdin);
ios::sync_with_stdio(false);
LL a,b;
scanf("%I64d%I64d",&a,&b);
LL c=min(a,b);
LL ans=1;
for(LL i=2;i<=c;i++)
ans=ans*i;
printf("%I64d\n",ans);
return 0;
}

  

Crossword solving

水题

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const LL N=1,M=1,MOD=1; int main()
{//freopen("t.txt","r",stdin);
ios::sync_with_stdio(false);
int n,m;
char a[2000],b[2000];
scanf("%d%d",&n,&m);
scanf("%s%s",&b,&a);
vector<int>pos;
pos.resize(n+1);
for(int i=0;i+n-1<m;i++)
{
vector<int>pon;
for(int j=0;j<n;j++)
{
if(a[i+j]!=b[j])pon.push_back(j+1);
}
if(pon.size()<pos.size())pos=pon;
}
printf("%d\n",pos.size());
for(int i=0;i<pos.size();i++)
{
printf("%d ",pos[i]);
}
printf("\n");
return 0;
}

  

Hacker, pack your bags!

比较裸的线段树,Mdzz 一开始没用LL WA了好几发 线段树写的还不是很熟练。。 最后调出来没时间看后边的题了!!

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const LL N=200005,M=15000000,MOD=1;
LL L[N],R[N],C[N];
int rt1[N],rt2[N],lc[M],rc[M],sumc[M],tot;
int n,x;
void update(int cur)
{
sumc[cur]=2e9+10;
if(lc[cur]!=0)sumc[cur]=min(sumc[cur],sumc[lc[cur]]);
if(rc[cur]!=0)sumc[cur]=min(sumc[cur],sumc[rc[cur]]);
}
void insert(int cur,int val,int cost,int l,int r)
{
if(l==r&&l==val){if(sumc[cur]==0)sumc[cur]=cost;else sumc[cur]=min(sumc[cur],cost);return ;}
int mid=(l+r)/2;
if(val<=mid)
{
if(lc[cur]==0)lc[cur]=++tot;
insert(lc[cur],val,cost,l,mid);
}
else
{
if(rc[cur]==0)rc[cur]=++tot;
insert(rc[cur],val,cost,mid+1,r);
}
update(cur);
}
LL que1(int cur,int vl,int vr,int l,int r)
{
if(cur==0||r<vl||l>vr)return 2e9+10;
if(r<=vr&&l>=vl)return sumc[cur];
int mid=(l+r)/2;
LL ret=2e9+10;
if(vl<=mid)ret=min(ret, que1(lc[cur],vl,min(mid,vr),l,mid));
if(vr>mid) ret=min( ret,que1(rc[cur],max(vl,mid+1),vr,mid+1,r));
return ret;
}
int main()
{//freopen("t.txt","r",stdin);
ios::sync_with_stdio(false);
scanf("%d%d",&n,&x);
for(int i=1;i<=n;i++)
{
scanf("%I64d%I64d%I64d",&L[i],&R[i],&C[i]);
int len=R[i]-L[i]+1;
if(rt1[len]==0&&rt2[len]==0)rt1[len]=++tot,rt2[len]=++tot;
insert(rt1[len],R[i],C[i],1,N);insert(rt2[len],L[i],C[i],1,N);
}
LL ans=2e9+10;
for(int i=1;i<=n;i++)
{
int len=R[i]-L[i]+1;
if(len>=x)continue;
ans=min(ans,C[i]+min(que1(rt1[x-len],1,L[i]-1,1,N),que1(rt2[x-len],R[i]+1,N,1,N)));
}
if(ans==2e9+10)printf("-1\n");
else printf("%I64d\n",ans);
return 0;
}

  

My pretty girl Noora

Liar

Madness

codeforces round 422 div2 补题 CF 822 A-F的更多相关文章

  1. codeforces round 421 div2 补题 CF 820 A-E

    A Mister B and Book Reading  O(n)暴力即可 #include<bits/stdc++.h> using namespace std; typedef lon ...

  2. Codeforces round 419 div2 补题 CF 816 A-E

    A Karen and Morning 水题 注意进位即可 #include<bits/stdc++.h> using namespace std; typedef long long i ...

  3. codeforces round 418 div2 补题 CF 814 A-E

    A An abandoned sentiment from past 水题 #include<bits/stdc++.h> using namespace std; int a[300], ...

  4. codeforces round 417 div2 补题 CF 812 A-E

    A Sagheer and Crossroads 水题略过(然而被Hack了 以后要更加谨慎) #include<bits/stdc++.h> using namespace std; i ...

  5. codeforces round 416 div2 补题 CF 811 A B C D E

    A. Vladik and Courtesy 水题略过 #include<cstdio> #include<cstdlib> #include<cmath> usi ...

  6. codeforces round 420 div2 补题 CF 821 A-E

    A Okabe and Future Gadget Laboratory 暴力 #include<bits/stdc++.h> using namespace std; typedef l ...

  7. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  8. codeforces 447 A-E div2 补题

    A DZY Loves Hash 水题 #include<iostream> #include<cstdio> #include<cstdlib> #include ...

  9. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

随机推荐

  1. How to resolve 'Potential Leak' issue

    -1 down vote favorite I am using the 'analyze' tool in xcode to check for potential leakages in my a ...

  2. BUPT复试专题—找K小数(2011)

    https://www.nowcoder.com/practice/204dfa6fcbc8478f993d23f693189ffd?tpId=67&tqId=29637&rp=0&a ...

  3. HDU2897( 巴什博奕变形)

    邂逅明下 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submissi ...

  4. Ubuntu16.04安装openjdk-7-jdk

    ubuntu14.04 升级16.04后会默认将jdk1.7删除,因此需要重新安装. Ubuntu16.04 安装Oracle JDK 和 Open jdk 默认JDK 安装比较轻松,但根据项目调整 ...

  5. c程序设计语言第一章3

    字符数组是C语言中最常用的数组类型.下面我们通过编写一个程序,来说明字符数组以反操作字符数组的函数的用法.该程序读入一组文本行,并把最长的文水行打印出来.该算法的基本框架非常简单: while (还有 ...

  6. 优化你的服务器Apache、MySQL、PHP

    硬件上的考虑其实起50%的作用,当然是越快越好.如果不知道哪个快,就换成越贵越好.可实际上不可能做到这些,因为银子有限,所以按照这个顺序考虑:内存越大越好->硬盘SCSI好于SATA->C ...

  7. SQL server 子查询的应用

    设置主键关联表格 时间函数的应用

  8. LA4043 - Ants(二分图完备最佳匹配KM)

    option=com_onlinejudge&Itemid=8&page=show_problem&problem=2044">https://icpcarch ...

  9. NYOJ 1067 Compress String(区间dp)

    Compress String 时间限制:2000 ms  |  内存限制:65535 KB 难度:3 描写叙述 One day,a beautiful girl ask LYH to help he ...

  10. Ubuntu安装教程--Win7系统中含100M保留分区

    1.检查 Win7 保留分区 1)进入 Win7 打开库目录.在左側栏找到"计算机",瞄准点右键选择"管理"菜单: 2)在出来的管理面板左边找到"磁盘 ...