zoukankan      html  css  js  c++  java
  • 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;
        }
    }
    
  • 相关阅读:
    es6的解构赋值
    防抖
    resources saver 实现资源批量下载
    flutter了解
    export, export default 和 import的使用
    5,vue过滤和高阶函数
    4,v-for循环
    3,v-if的使用
    2,v-on绑定事件和修饰符
    怎样统一管理vue项目中的大量api和异步操作
  • 原文地址:https://www.cnblogs.com/YDDDD/p/12122464.html
Copyright © 2011-2022 走看看