感觉这场的题面都好长,看的脑壳子疼(英语不好,啊我挂了
http://codeforces.com/contest/1075
A. The King's Race
考虑对角线为分界
#include <iostream>
using namespace std;
int main() {
long long n,x,y;
cin>>n>>x>>y;
if((x+y)<=n+1)cout<<"White";
else cout<<"Black";
return 0;
}
B. Taxi drivers and Lyft
每个0都会选择离他近的1,预处理一下每个0的前后最近的1的位置,然后跑一边就能算出每个0应该会归属哪个1了
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
ll n,m;
ll res[maxn];
struct T{
ll pre;
ll last;
}tt[maxn];
ll x[maxn];
ll type[maxn];
int main(){
scanf("%lld%lld",&n,&m);
for(int i=0;i<n+m;++i){
scanf("%lld",x+i);
}
for(int i=0;i<n+m;++i){
scanf("%lld",type+i);
}
ll pp=-1e9;
for(int i=0;i<n+m;++i){//更新前驱
if(type[i]==0){
tt[i].pre=pp;
}
else{
pp=i;
}
}
ll la=1e9+5;
for(int i=n+m-1;i>=0;--i){//更新后继
if(type[i]==0){
tt[i].last=la;
}
else{
la=i;
}
}
for(int i=0;i<m+n;++i){
if(type[i]==0){
if(tt[i].last==1e9+5){
res[tt[i].pre]++;
}
else if(tt[i].pre==(-1e9)){
res[tt[i].last]++;
}
else{
ll xx=x[i]-x[tt[i].pre];
ll yy=x[tt[i].last]-x[i];
if(xx<=yy){
res[tt[i].pre]++;
}
else{
res[tt[i].last]++;
}
}
}
}
for(int i=0;i<n+m;++i){
if(type[i]==1){
cout<<res[i]<<' ';
}
}
return 0;
}
C. The Tower is Going Home
单独写了一下https://blog.youkuaiyun.com/TDD_Master/article/details/83960783
后面的题交的人好少,立个flag,来补