​link​

题意:让你将点的集合划分成两个,然后两集合之间的距离没有在集合内部出现。

思路:

一开始以为是二分图啥的,结果是思维,考虑把点划分成4类,00,01,10,11,

0代表奇点,1代表偶点,然后如果存在两个不同类的点就可以划分,把00,11放在一起,01,10放在一起,如果符合的话,如果只存在一个集合的点,那么我们就把所有点就/2,改变其奇偶性,直到出现解位置。

复杂度n*log2e6

(写个jvavhhh)代码:

import java.math.*;
import java.util.*;

import java.io.*;

//import org.graalvm.compiler.lir.alloc.lsra.ssa.SSALinearScan;

public class Main{
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;

public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}

public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}

public int nextInt() {
return Integer.parseInt(next());
}

}
static int x[]=new int [1010];
static int y[]=new int [1010];
static int num[][]=new int [2][2];
public static void main(String[] args)
{
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
int n=in.nextInt();
for(int i=1;i<=n;i++)
{
x[i]=in.nextInt();
y[i]=in.nextInt();
x[i]+=1000000;
y[i]+=1000000;
}

while(true)
{
out.flush();
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
num[i][j]=0;
for(int i=1;i<=n;i++)
num[x[i]%2][y[i]%2]++;
Vector ans=new Vector(0);
boolean flag=false;
if(((num[0][0]+num[1][1]>0)&(num[1][0]+num[0][1])>0))
{
for(int i=1;i<=n;i++)
{
if(x[i]%2==0 && y[i]%2==0 || x[i]%2==1 && y[i]%2==1) ans.add(i);
}
out.println(ans.size());
Iterator it = ans.iterator();
while(it.hasNext())
out.printf("%d ", it.next());
out.flush();
break;
}
if(num[0][0]>0 && num[1][1]>0)
{
for(int i=1;i<=n;i++)
{
if(x[i]%2==0 && y[i]%2==0 ) ans.add(i);
}
out.println(ans.size());
Iterator it = ans.iterator();
while(it.hasNext())
out.printf("%d ", it.next());
out.flush();
break;
}
if(num[1][0]>0 && num[0][1]>0)
{
for(int i=1;i<=n;i++)
{
if(x[i]%2==0 && y[i]%2==1 ) ans.add(i);
}
out.println(ans.size());
Iterator it = ans.iterator();
while(it.hasNext())
out.printf("%d ", it.next());
out.flush();
break;
}
if(flag==true) break;
for(int i=1;i<=n;i++)
{
x[i]/=2;y[i]/=2;
}
}

out.flush();
}
}