結果
| 問題 |
No.635 自然門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-19 03:27:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 671 bytes |
| コンパイル時間 | 2,106 ms |
| コンパイル使用メモリ | 199,120 KB |
| 最終ジャッジ日時 | 2025-01-15 11:41:58 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 WA * 13 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:9:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | rep(i,3) scanf("%d",&x[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | rep(i,3) scanf("%d",&v[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:35:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | int q; scanf("%d",&q); rep(_,q) solve();
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
void solve(){
int x[3],v[3];
rep(i,3) scanf("%d",&x[i]);
rep(i,3) scanf("%d",&v[i]);
vector<double> T={0};
rep(i,3) rep(j,3) if(i!=j) {
if(x[i]<x[j] && v[i]>v[j]){
// x_i+v_i*t = x_j+v_j*t <=> t = (x_j-x_i)/(v_i-v_j)
T.emplace_back(double(x[j]-x[i])/(v[i]-v[j]));
}
}
sort(T.begin(),T.end());
rep(i,T.size()-1){
double t=(T[i]+T[i+1])/2;
double a[3];
rep(j,3) a[j]=x[j]+v[j]*t;
if((a[0]>a[1] && a[1]<a[2]) || (a[0]<a[1] && a[1]>a[2])){
puts("YES");
return;
}
}
puts("NO");
}
int main(){
int q; scanf("%d",&q); rep(_,q) solve();
return 0;
}