Codeforces Round #431 (Div. 2) 题解
来源:互联网 发布:java根据ip获取运营商 编辑:程序博客网 时间:2024/05/19 04:56
Codeforces Round #431 (Div. 2)
A:
水
#include<bits/stdc++.h>using namespace std;typedef long long ll;int a[107];int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&a[i]); if(a[1]%2&&a[n]%2&&n%2) puts("Yes"); else puts("No"); return 0;}
B: check
。
#include<bits/stdc++.h>using namespace std;typedef long long ll;ll ky,kx;ll y[1007];bool check(int i,int j){ return (y[j]-y[i])*kx==(j-i)*ky;}int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%I64d",&y[i]); // 1 not connect any other point ky=y[3]-y[2],kx=1; bool ok=false,nice=true; for(int i=4;i<=n;++i) if(!check(2,i)) nice=false; if(nice&&!check(1,2)) ok=true; for(int i=2;i<=n;++i) { vector<int> rm; ky=y[i]-y[1];kx=i-1; for(int j=2;j<=n;++j) { if(j==i) continue; if(!check(1,j)) rm.push_back(j); } if(!rm.size()) continue; if(rm.size()==1) ok=true; else { bool nice=true; for(int j=1;j<rm.size();++j) if(!check(rm[0],rm[j])) nice=false; if(nice) ok=true; } } puts(ok?"Yes":"No"); return 0;}
C:
好像怎么合并与最小消耗无关。所以直接考虑每一个字母的数量就行
#include<bits/stdc++.h>using namespace std;typedef long long ll;int c[1007];int main(){ int n; scanf("%d",&n); for(int i=1;i<=1000;++i) c[i]=(i+1)*i/2; vector<int> ans; for(int i=25;i>=0;--i) { for(int j=1000;j>=0;--j) if(c[j]<=n) { n-=c[j]; ans.push_back(j+1); break; } if(n==0) break; } for(int i=0;i<ans.size();++i) { for(int j=0;j<ans[i];++j) putchar('a'+i); } puts(""); return 0;}
D:
通过画图可以知道,
且出发的位置与终止的位置的顺序对于左上角-右下角这条直线对称。
#include<bits/stdc++.h>using namespace std;const int N=2e5+7;int n,w,h;struct Point{ int d,p,id; bool operator < (const Point & r) const { return p<r.p; }};vector<Point> px[N],py[N];int ansx[N],ansy[N],tmpx[N],tmpy[N];int main(){ scanf("%d%d%d",&n,&w,&h); for(int i=0;i<n;++i) { int g,p,t; scanf("%d%d%d",&g,&p,&t); if(g==1) px[p-t+100000].push_back({0,p,i}); else py[p-t+100000].push_back({1,p,i}); } for(int i=0;i<N;++i) sort(px[i].begin(),px[i].end()); for(int i=0;i<N;++i) sort(py[i].begin(),py[i].end()); for(int i=0;i<N;++i) { int cur=0; for(int j=0;j<px[i].size();++j) tmpx[cur]=px[i][j].p,tmpy[cur]=h,++cur; for(int j=(int)py[i].size()-1;j>=0;--j) tmpx[cur]=w,tmpy[cur]=py[i][j].p,++cur; cur=0; for(int j=(int)py[i].size()-1;j>=0;--j) ansx[py[i][j].id]=tmpx[cur],ansy[py[i][j].id]=tmpy[cur],++cur; for(int j=0;j<px[i].size();++j) ansx[px[i][j].id]=tmpx[cur],ansy[px[i][j].id]=tmpy[cur],++cur; } for(int i=0;i<n;++i) printf("%d %d\n",ansx[i],ansy[i]); return 0;}
阅读全文
0 0
- Codeforces Round #431 (Div. 2) 题解
- Codeforces Round #431 (Div. 2) 题解
- 【codeforces】Codeforces Round #276 (Div. 2) 题解
- 【codeforces】Codeforces Round #277 (Div. 2) 题解
- 【codeforces】Codeforces Round #279 (Div. 2) 题解
- 【codeforces】Codeforces Round #283 (Div. 2) 【题解】
- 【codeforces】Codeforces Round #291 (Div. 2) 题解
- Codeforces Round #431 (Div. 2) A. Odds and Ends 题解
- Codeforces Round #131 (Div. 2) 完整题解
- Codeforces Round #135 (Div. 2)题解
- Codeforces Round #192 (Div. 2) 题解报告
- Codeforces Round #194 (Div. 2) 题解
- Codeforces Round #216 (Div. 2)部分题解
- Codeforces Round #226 (Div. 2) 题解
- Codeforces Round #177 (Div. 2) 题解
- Codeforces Round #FF (Div. 2) 题解
- Codeforces Round #256 (Div. 2) 题解
- Codeforces Round #257 (Div. 2) 题解
- Rotate Image
- 浅析MVP设计模式
- 使用Python定制词云
- LeetCode-Reverse Nodes in k-Group
- Ceph网络模块(3)——AsyncMessenger代码流程分析
- Codeforces Round #431 (Div. 2) 题解
- ORACLE实例讲太多大道理还不如真正实际操作一次的教程
- Pythonday04
- Eigen random 产生随机数
- 为应用生成签名文件的两种方式
- 【bzoj1596】[Usaco2008 Jan]电话网络
- bzoj2817[ZJOI2012]波浪 DP+高精度
- Qt提升子部件的办法&如何重写提升后部件的事件处理函数
- Ubuntu16.04下PX4环境快速搭建及uORB通信机制