Codeforces Round #422 (Div. 2) 解题报告
来源:互联网 发布:服装设计淘宝 编辑:程序博客网 时间:2024/04/24 09:44
A. I’m bored with life
//Author: Lixiang#include<stdio.h>struct A{ int A,B; void init(){ scanf("%d%d",&A,&B); } void work(){ if(A>B){ int t=A; A=B; B=t; } int s=1; for(int i=1;i<=A;i++) s*=i; printf("%d\n",s); }}sol;int main(){ sol.init(); sol.work(); return 0;}
B. Crossword solving
//Author: Avneet#include<bits/stdc++.h>using namespace std;int n,m,i,j,c,a=2e9,ai;string s,t;int main(){cin>>n>>m>>s>>t;for(i=0;i<=m-n;i++){ for(c=j=0;j<n;j++) t[i+j]==s[j]?0:c++; c<a?a=c,ai=i:0;}cout<<a<<endl;for(c=j=0;j<n;j++) t[ai+j]!=s[j]?cout<<j+1<<" ",0:0;}
C. Hacker, pack your bags!
#include<bits/stdc++.h>#define F(i,a,b) for(int i=(a);i<=(b);++i)using namespace std;typedef long long ll;typedef pair<int,int>P;const int N=2e5+7;int n,m;vector<P>L[N],R[N];ll c[N],ans;int main(){ F(i,1,N-1)c[i]=INT_MAX; scanf("%d%d",&n,&m); F(i,1,n) { int l,r,v; scanf("%d%d%d",&l,&r,&v); L[l].push_back({r-l+1,v}); R[r].push_back({r-l+1,v}); } ans=INT_MAX; F(i,1,N-1) { for(auto &it:L[i]) { if(it.first>=m)continue; ans=min(ans,c[m-it.first]+it.second); } for(auto &it:R[i]) c[it.first]=min(c[it.first],1ll*it.second); } printf("%I64d\n",ans==INT_MAX?-1:ans); return 0;}
阅读全文
0 0
- Codeforces Round #422 (Div. 2) 解题报告
- Codeforces Round #149 (Div. 2)解题报告
- Codeforces Round #180 (Div. 2) 解题报告
- Codeforces Round #190 (Div. 2) 解题报告
- Codeforces Round #191 (Div. 2) 解题报告
- Codeforces Round #189 (Div. 2) 解题报告
- Codeforces Round #142 (Div. 2) 解题报告
- Codeforces Round #229 (Div. 2) 解题报告
- Codeforces Round #241 (Div. 2) 解题报告
- Codeforces Round #262 (Div. 2)解题报告
- Codeforces Round #267 (Div. 2) 解题报告
- Codeforces Round #266 (Div. 2)解题报告
- Codeforces Round #268 (Div. 2) 解题报告
- Codeforces Round #271 (Div. 2) 解题报告
- Codeforces Round #274 (Div. 2) 解题报告
- Codeforces Round #276 (Div. 2) 解题报告
- Codeforces Round #277 (Div. 2) 解题报告
- Codeforces Round #224 (Div. 2)解题报告
- Strut2中strus.xlm文件的配置详解
- Android事件分发机制
- Java+Selenium3框架设计准备篇4-TestNG实现DDT(2)
- 使用jsoup获取页面元素
- R语言报告 单因素方差分析
- Codeforces Round #422 (Div. 2) 解题报告
- python 类
- 希尔排序
- Leetcode OJ 73 Set Matrix Zeroes [Medium]
- asp.net 快速简单的导出数据 DataTable导出到Excel、GSV
- hdu 2642 Stars(二维数组 单点更新 区间查询)
- C#深度拷贝,浅拷贝
- string and stringstream(1)
- Linux系统-git分支相关操作