# 笔试

1 <= T <= 10

1 <= h, w <= 104

2
1345 2584
2584 683
2584 1345
683 1345
683 1345
2584 683
1234 4567
1234 4567
4567 4321
4322 4567
4321 1234
4321 1234

POSSIBLE
IMPOSSIBLE

import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class S6 {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n;
n = in.nextInt();
in.nextLine();
HashMap<Node, Integer> map = new HashMap<>();
int k=0;
for (int i = 0; i < (n * 6)-1; i++) {
String[] split = in.nextLine().split(" ");
int r1 = Integer.parseInt(split[0]);
int r2 = Integer.parseInt(split[1]);
if (r1 > r2) {
int temp = r1;
r1 = r2;
r2 = temp;
}
Node node = new Node();
node.h = r1;
node.w = r2;
if (map.get(node) != null) {
map.put(node, 2);
}else {
map.put(node, 1);
}
if(k==5) {
k=0;
Iterator<Entry<Node, Integer>> it = map.entrySet().iterator();
int count=0;
while(it.hasNext()){
Entry<Node, Integer> next = it.next();
Integer value = next.getValue();
if(value==2) {
count++;
}
}
if(count==3) {
System.out.println("POSSIBLE");
}else {
System.out.println("IMPOSSIBLE");
}
map.clear();
}
k++;
}
}
}

class Node {
int h;
int w;
int count = 0;

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + h;
result = prime * result + w;
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Node other = (Node) obj;
if (h != other.h)
return false;
if (w != other.w)
return false;
return true;
}
}

A：1→2  si--->ti

B：2→3 si--->ti

C：1→3 si--->ti

1 <= n <= 1000

1 <= si < ti <= 105

10
84 302
275 327
364 538
26 364
29 386
545 955
715 965
404 415
903 942
150 402

6

暂时没有思路

posted @ 2020-04-18 21:23  ---dgw博客  阅读(136)  评论(0编辑  收藏