zoukankan      html  css  js  c++  java
  • Codeforces Round #245 (Div. 2)A. Points and Segments (easy)(思维)

    题目链接
    大意:给你一系列的点和区间,给每个点上一种颜色(共两种颜色),要求每个区间内的两种颜色数量的差不超过1.
    思路:先排序从小到大,然后按奇偶这样分布不同的颜色。这样就保证每个区间内的颜色差不超过1.
    妥妥的降智题啊。

    #include<bits/stdc++.h>
    
    #define LL long long
    #define fi first
    #define se second
    #define mp make_pair
    #define pb push_back
    
    using namespace std;
    
    LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
    LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
    LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
    const int N = 2e5 +11;
    int n,m,a[N];
    struct uzi
    {
    	int a,i;
    	bool operator <(const uzi & t)const{
    		return a<t.a;
    	}
    }p[N];
    int ans[N];
    int main(){
    	ios::sync_with_stdio(false);
    	cin>>n>>m;
    	for(int i=1;i<=n;i++)cin>>p[i].a,p[i].i=i;
    	sort(p+1,p+1+n);
    	for(int i=1;i<=m;i++){int s,t;cin>>s>>t;}
    	for(int i=1;i<=n;i++)if(i&1)ans[p[i].i]=1;
    	for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
    
    	return 0;
    }
    
  • 相关阅读:
    闭包
    关于this
    插件开发(对象级)
    IFC
    flex.css
    js移动端滑动事件
    Android 手机下输入框获取焦点时, 输入法挡住输入框的 bug
    vue 组件化spreadjs预览excel
    feign 熔断工厂 fallbackFactory的简单实现
    bat脚本批量启动程序
  • 原文地址:https://www.cnblogs.com/pubgoso/p/10829008.html
Copyright © 2011-2022 走看看