题解 | #交叉线#
交叉线
https://www.nowcoder.com/practice/54fe00d9b0e14688bd3d31ad539b929c?tpId=182&tqId=34654&rp=1&ru=/exam/oj&qru=/exam/oj&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26pageSize%3D50%26search%3D%26tab%3D%25E5%2590%258D%25E4%25BC%2581%25E7%259C%259F%25E9%25A2%2598%26topicId%3D182&difficulty=undefined&judgeStatus=undefined&tags=&title=
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void (async function () { // Write your code here while ((line = await readline())) { n = parseInt(line); while (n-- > 0) { m = parseInt(await readline()); arr = await readline(); arrs = arr.split(" "); var cir = new Array(); for (let j = 0; j < m; j = j + 2) { let left = Math.min(arrs[j], arrs[j + 1]); let right = Math.max(arrs[j], arrs[j + 1]); cir.push([left, right]); } var flag = false; for (let i = 1; i < cir.length; i++) { for (let j = 0; j < i; j++) { var left1 = Number(cir[i][0]); var right1 = Number(cir[i][1]); var left2 = Number(cir[j][0]); var right2 = Number(cir[j][1]); if ((left1 < left2) && (right1 < right2) && (right1 > left2)) { flag = true; break; } else if ( (left1 > left2) && (right1 > right2) && (right2 > left1) ) { flag = true; break; } } } if (flag) { console.log("y"); } else { console.log("n"); } } } })();