【题解】CF1971C Clock and Strings

题解:CF1971C Clock and Strings

题意

在上图的一个圆中,给予你四个点 \(a,b,c,d\),判断线段 \(ab\) 与线段 \(cd\) 是否相交。

思路

先设置一个字符串 \(s\)

\(1\)\(12\) 扫描,如果扫描到 \(a,b\),则在 \(s\) 中加入 \(a\),如果扫到 \(c,d\),则加入 \(b\)

经过实践足以证明,若 \(ab\)\(cd\) 相交,\(s\) 必为 \(abab\)\(baba\)

Ac code

#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,t;
int main() {
	cin>>t;
	while(t--) {
		cin>>a>>b>>c>>d;
		string s;
		for (int i=1;i<=12;i++) {
			if(i==a||i==b)s+="a";
			if(i==c||i==d)s+="b";
		}
		if(s=="abab"||s=="baba"){
			cout<<"YES\n";
		}else{
			cout<<"NO\n";
		}
	}
	return 0;
}
posted @ 2024-05-16 17:26  Kcjhfqr  阅读(53)  评论(0)    收藏  举报
.poem-wrap { position: relative; width: 1000px; max-width: 80%; border: 2px solid #797979; border-top: none; text-align: center; margin: 40px auto; } .poem-left { left: 0; } .poem-right { right: 0; } .poem-border { position: absolute; height: 2px; width: 27%; background-color: #797979; } .poem-wrap p { width: 70%; margin: auto; line-height: 30px; color: #797979; } .poem-wrap h1 { position: relative; margin-top: -20px; display: inline-block; letter-spacing: 4px; color: #797979; font-size: 2em; margin-bottom: 20px; } #poem_sentence { font-size: 25px; } #poem_info { font-size: 15px; margin: 15px auto; }