結果

問題 No.635 自然門松列
ユーザー DAyamaCTFDAyamaCTF
提出日時 2018-01-19 21:58:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 650 ms
コード長 1,460 bytes
コンパイル時間 1,244 ms
コンパイル使用メモリ 150,904 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 13:07:50
合計ジャッジ時間 2,343 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0