• 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;
    }
    
  • 相关阅读:
    Python面试
    PyCharm快捷键
    PyCharm安装及使用
    Python环境搭建
    MYSQL的cmake编译单实例安装
    lamp和lnmp环境的搭建
    模拟解决DOS攻击的shell脚本
    责任链模式
    迭代器模式
    备忘录设计模式
  • 原文地址:https://www.cnblogs.com/pubgoso/p/10829008.html
Copyright © 2020-2023  润新知