結果
問題 | No.635 自然門松列 |
ユーザー | DAyamaCTF |
提出日時 | 2018-01-19 21:58:54 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 650 ms |
コード長 | 1,460 bytes |
コンパイル時間 | 1,504 ms |
コンパイル使用メモリ | 164,336 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 08:47:10 |
合計ジャッジ時間 | 2,208 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rep(i,n) repl(i,0,n) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define mmax(x,y) (x>y?x:y) #define mmin(x,y) (x<y?x:y) #define maxch(x,y) x=mmax(x,y) #define minch(x,y) x=mmin(x,y) #define uni(x) x.erase(unique(all(x)),x.end()) #define exist(x,y) (find(all(x),y)!=x.end()) #define bcnt __builtin_popcount #define INF 1e16 ll q; bool judge(vector<double> a){ rep(i,3){ if(a[i]==a[(i+1)%3])return false; } if(*max_element(all(a))==a[1]||*min_element(all(a))==a[1])return true; else return false; } int main(){ cin>>q; while(q--){ vector<double> b,a; b.resize(3); a.resize(3); rep(i,3)cin>>b[i]; rep(i,3)cin>>a[i]; if(judge(b)){ cout<<"YES"<<endl; continue; } vector<double> tx; rep(i,3){ int j=(i+1)%3; if(a[i]==a[j])continue; double x=-((b[i]-b[j])/(a[i]-a[j])); if(x<-1e-9)continue; tx.push_back(x); } bool ok=false; rep(i,tx.size()){ double x=tx[i]; x+=0.000001; vector<double> tmp; rep(j,3){ tmp.push_back(a[j]*x+b[j]); } if(judge(tmp)){ ok=true; cout<<"YES"<<endl; break; } } if(!ok)cout<<"NO"<<endl; } return 0; }