Codeforces_849
A.只要考虑分成一个串的情况就可以了。
#include<bits/stdc++.h>
using namespace std; int n,a[]; int main()
{
ios::sync_with_stdio();
cin >> n;
for(int i = ;i <= n;i++) cin >> a[i];
if(a[]% && a[n]% && n%) cout << "Yes" << endl;
else cout << "No" << endl;
return ;
}
B.1.若所有点在一条直线,则no。
2.若a[1]单独一组,剩余点在一条直线,则yes。
3.枚举a[1]和后面点组成的直线,判断是否能把点分成两组。
#include<bits/stdc++.h>
using namespace std; int n,a[]; int main()
{
ios::sync_with_stdio();
cin >> n;
for(int i = ;i <= n;i++) cin >> a[i];
int t = a[]-a[];
int ok = ;
for(int i = ;i <= n;i++)
{
if(a[i]-a[i-] != t) ok = ;
}
if(!ok)
{
if(a[]-a[] == t) cout << "No" << endl;
else cout << "Yes" << endl;
return ;
}
ok = ;
for(int i = ;i <= n;i++)
{
double t = 1.0*(a[i]-a[])/(i-);
vector<int> v;
for(int j = ;j <= n;j++)
{
if(abs(1.0*(a[j]-a[])/(j-)-t) > 1e-) v.push_back(j);
}
int flag = ;
for(int j = ;j < v.size();j++)
{
if(abs(1.0*(a[v[j]]-a[v[]])/(v[j]-v[])-t) > 1e-) flag = ;
}
if(flag) ok = ;
}
if(ok) cout << "Yes" << endl;
else cout << "No" << endl;
return ;
}
C.首先,每个字母相互独立。对于每个字母,最优的方案是一个一个加,打个表,每次加个最大可行量。注意0的特殊情况。
#include<bits/stdc++.h>
using namespace std; int n,x[];
string ans = "z"; int main()
{
ios::sync_with_stdio();
x[] = ;
for(int i = ;i <= ;i++) x[i] = x[i-]+i-;
cin >> n;
for(char c = 'a';c <= 'z';c++)
{
if(n == ) break;
int t = ;
while(x[t] > n) t--;
n -= x[t];
while(t--) ans.append(,c);
}
cout << ans << endl;
return ;
}
D.分成两组,按照g-t排序,这个顺序保证相遇顺序。
之后双指针模拟,遇到连续的几个相同时,画个图便知道那个点从哪里出了。
#include<bits/stdc++.h>
using namespace std; int n,w,h,tx[],ty[],ansx[],ansy[];
struct xx
{
int x,t,id;
friend bool operator<(xx a,xx b)
{
if(a.x-a.t != b.x-b.t) return a.x-a.t < b.x-b.t;
return a.x < b.x;
}
}a[],b[]; int main()
{
ios::sync_with_stdio();
cin >> n >> w >> h;
int cnt1 = ,cnt2 = ;
for(int i = ;i <= n;i++)
{
int x,y,t;
cin >> x >> y >> t;
if(x == )
{
a[++cnt1].x = y;
a[cnt1].t = t;
a[cnt1].id = i;
tx[i] = y;
ty[i] = h;
}
else
{
b[++cnt2].x = y;
b[cnt2].t = t;
b[cnt2].id = i;
tx[i] = w;
ty[i] = y;
}
}
sort(a+,a++cnt1);
sort(b+,b++cnt2);
int now1 = ,now2 = ;
while(now1 <= cnt1 && now2 <= cnt2)
{
if(a[now1].x-a[now1].t == b[now2].x-b[now2].t)
{
int t1 = now1+,t2 = now2+;
while(t1 <= cnt1 && a[now1].x-a[now1].t == a[t1].x-a[t1].t) t1++;
while(t2 <= cnt2 && b[now2].x-b[now2].t == b[t2].x-b[t2].t) t2++;
vector<int> v1,v2;
for(int i = now1;i < t1;i++) v1.push_back(a[i].id);
for(int i = t2-;i >= now2;i--) v1.push_back(b[i].id);
for(int i = t2-;i >= now2;i--) v2.push_back(b[i].id);
for(int i = now1;i < t1;i++) v2.push_back(a[i].id);
for(int i = ;i < v1.size();i++)
{
ansx[v2[i]] = tx[v1[i]];
ansy[v2[i]] = ty[v1[i]];
}
now1 = t1;
now2 = t2;
}
else if(a[now1].x-a[now1].t < b[now2].x-b[now2].t)
{
ansx[a[now1].id] = tx[a[now1].id];
ansy[a[now1].id] = ty[a[now1].id];
now1++;
}
else
{
ansx[b[now2].id] = tx[b[now2].id];
ansy[b[now2].id] = ty[b[now2].id];
now2++;
}
}
while(now1 <= cnt1)
{
ansx[a[now1].id] = tx[a[now1].id];
ansy[a[now1].id] = ty[a[now1].id];
now1++;
}
while(now2 <= cnt2)
{
ansx[b[now2].id] = tx[b[now2].id];
ansy[b[now2].id] = ty[b[now2].id];
now2++;
}
for(int i = ;i <= n;i++) cout << ansx[i] << " " << ansy[i] <<endl;
return ;
}
Codeforces_849的更多相关文章
随机推荐
- vue使用axios调用接口
vue本身不支持ajax接口的请求,所以在vue中经常使用axios这个接口请求工具,这个axios也是vue官方推荐的库.axios的官方github: https://github.com/mza ...
- tomcat服务器基本操作:实现www.baidu.com访问tomcat中项目
0.实现用其他的域名,而不再使用localhost:8080/xxx,访问tomcat中的项目: (1). 修改访问tomcat的端口号: (2). tomcat配置虚拟主机: (3). 本地DNS解 ...
- docker-bind挂载
使用绑定挂载 自Docker早期以来,绑定挂载一直存在.与卷相比,绑定装载具有有限的功能.使用绑定装入时,主机上的文件或目录将装入容器中.文件或目录由其在主机上的完整路径或相对路径引用.相反,当您使用 ...
- 体验.NET Core 命令行应用程序-CommandLineUtils
前言 在我们开发中可能需要设计一次性应用程序,这些实用程序可以利用接近原始源代码的优势,但可以在与主Web应用程序完全独立的安全性上下文中启动.具体在 [管理过程](https://12factor. ...
- Educational Codeforces Round 80 (Rated for Div. 2)
A. Deadline 题目链接:https://codeforces.com/contest/1288/problem/A 题意: 给你一个 N 和 D,问是否存在一个 X , 使得 $x+\lce ...
- Python自带HTTP文件传输服务
一行命令搭建一个基于python的http文件传输服务 由于今天朋友想要一个文件,而我恰好有,因为这个文件比较大,网速不是很给力,所以想到了python自己有这么一个功能,这样不仅不需要下载其他软件, ...
- Nginx代理服务——反向代理
Nginx可以代理的服务 正向代理,例如翻墙 反向代理 正向和反向代理的区别 区别在于代理的对象不一样 正向代理:代理的对象是客户端 反向代理:代理的对象是服务器 配置语法 Synta ...
- Vue 组件 传值
注意 Vue模板只能有一个对象,要想用多个对象时用div包裹 一.父组件->子组件 通过props 1.子组件: 声明:proprs =[‘xx’],xx是在父组件中引用子组件,子组件的属性(t ...
- Qt Installer Framework翻译(4)
教程:创建安装程序 本教程描述如何为一个小项目创建一个简单的安装程序: 本节描述创建安装程序所必须完成的步骤: 创建一个包文件夹,其中将包含所有配置文件和可安装的包. 创建一个配置文件,其中包含有关如 ...
- Java解析XML文件的方式
在项目里,我们往往会把一些配置信息放到xml文件里,或者各部门间会通过xml文件来交换业务数据,所以有时候我们会遇到“解析xml文件”的需求.一般来讲,有基于DOM树和SAX的两种解析xml文件的方式 ...