• Good Bye 2019 E. Divide Points


    链接:

    https://codeforces.com/contest/1270/problem/E

    题意:

    You are given a set of n≥2 pairwise different points with integer coordinates. Your task is to partition these points into two nonempty groups A and B, such that the following condition holds:

    For every two points P and Q, write the Euclidean distance between them on the blackboard: if they belong to the same group — with a yellow pen, and if they belong to different groups — with a blue pen. Then no yellow number is equal to any blue number.

    It is guaranteed that such a partition exists for any possible input. If there exist multiple partitions, you are allowed to output any of them.

    思路:

    可以按照xy的和分类,和的奇数偶数都有根据奇偶数分类,否则x和y的两种情况分类。
    实现起来也不会。。围观了T神的代码

    代码:

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    
    int x[1010], y[1010];
    int n;
    
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0), cout.tie(0);
        cin >> n;
        for (int i = 1;i <= n;i++)
            cin >> x[i] >> y[i];
        for (int i = n;i >= 1;i--)
            x[i] -= x[1], y[i] -= y[1];
        while(true)
        {
            vector<int> vec;
            for (int i = 1;i <= n;i++) if ((x[i]+y[i])&1)
                vec.push_back(i);
            if (!vec.empty())
            {
                cout << (int)vec.size() << "
    ";
                for (int i = 0;i < (int)vec.size();i++)
                    cout << vec[i] << ' ';
                cout << "
    ";
                return 0;
            }
            for (int i = 2;i <= n;i++) if (x[i]&1)
                vec.push_back(i);
            if (!vec.empty())
            {
                cout << (int)vec.size() << "
    ";
                for (int i = 0;i < (int)vec.size();i++)
                    cout << vec[i] << ' ' ;
                cout << "
    ";
                return 0;
            }
            for (int i = 1;i <= n;i++)
                x[i]/=2, y[i]/=2;
        }
    }
    
  • 相关阅读:
    Linux中的邮件发送
    Python学习笔记18-发送邮件
    Ansible学习笔记
    eclipse使用maven打包时去掉测试类
    CentOS安装redis
    spring boot 部署
    sprint boot 配置
    spring-boot 学习笔记一
    不要容忍破窗户
    阿里云安装Oracle
  • 原文地址:https://www.cnblogs.com/YDDDD/p/12122464.html
Copyright © 2020-2023  润新知