結果

問題 No.2564 衝突予測
ユーザー naimonon77naimonon77
提出日時 2024-01-10 00:26:07
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,533 bytes
コンパイル時間 2,580 ms
コンパイル使用メモリ 164,712 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-27 20:06:56
合計ジャッジ時間 6,310 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 201 ms
6,940 KB
testcase_04 AC 199 ms
6,944 KB
testcase_05 AC 203 ms
6,940 KB
testcase_06 AC 199 ms
6,944 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define NOMINMAX
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <regex>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=(int)b;--i)
#define range(i,a,b,c) for(int i=a;c>0?i<b:i>b;i+=c)

#define chmax(a,b) (a=(a)<(b)?(b):(a))
#define chmin(a,b) (a=(a)>(b)?(b):(a))

//template<typename T>void out(T a) {T b=a;if(a==inf)b=-1;cout<<a<<endl;}
//#define out(a) cout<<(a)<<endl
//#define o2(a,b) cout<<(a)<<" ";out(b)
//#define o3(a,b,c) cout<<(a)<<" ";o2(b, c)
#define abp(o,a,b) out(((o)?a:b))
#define YEP(x) abp(x,"YES","NO")
#define Yep(x) abp(x,"Yes","No")


using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(!(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE==true
const bool test = true;
#define dump(x) cerr<<#x<<" : "<<(x)<< "   \t"
#define dumpl(x) dump(x)<<endl
#define cerr_endl cerr<<endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#define cerr_endl 
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#define cerr_endl 
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int inf = (int)1 << 60;
const int undefined = inf;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return(r > eps) - (r < -eps); }
int sgn(const Real& a, const Real& b) { return sgn(a - b); }

const int MAX = (int)2e6 + 5;
const int MAX2 = 2005;

vector<string> split(const string& str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) v.push_back(buffer); return v; }

string join(const vector<string>& v, const string delim = 0) { string s; if (!v.empty()) { s += v[0]; for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) { if (delim != "")s += delim; s += v[i]; } }return s; }

string operator*(const string& s, const int& n) { string res = ""; rep(i, n)res += s; return res; }

template<typename T>
int sum_f(T a) { return accumulate(all(a), 0ll); }

template<typename T>T gcd(T a, T b) { T c; while (a != 0) { c = a; a = b % a; b = c; }; return b; }
template<typename T>T bit_count(T N) { T c = 0; while (N) { if (N & 1)c++; N >>= 1; }return c; }


template<typename T>void p_vector(vector<pair<T, T>> a, ostream& o = cout) { rep(i, a.size())o << a[i].first << "," << a[i].second << " "; o << endl; }

template<typename T>void p_vector(vector<T> a, ostream& o = cout) { rep(i, a.size() - 1)o << a[i] << " "; o << a.back() << endl; }

ll pow_n(ll x, ll n) { ll r = 1; while (n > 0) { if (n & 1)r = (r * x) % mod_n; x = (x * x) % mod_n; n >>= 1; }return r; }

int H, W;

#define grid_ng(y,x) (y<0||y>=H||x<0||x>=W)

int div_ceil(int a, int b) { int r = a / b; if (a % b != 0)r++; return r; }

int math_div(int x, int m) {
	ll r = (x % m + m) % m;
	return (x - r) / m;
}

#define i1(a) cin>>a;
#define i2(a,b) cin>>a>>b;
#define i3(a,b,c) cin>>a;i2(b,c);
#define i4(a,b,c,d) cin>>a;i3(b,c,d);
#define i5(a,b,c,d,e) cin>>a;i4(b,c,d,e);


template<typename T>
vector<T> in_vec(int n) {
	vector<T> a(n);
	a.resize(n);
	rep(i, n) cin >> a[i];
	return a;
}

template<typename T>
vector<vector<int>> in_vec(int n, int m) {
	vector<vector<int>> a(n);
	rep(i, n) {
		a[i].resize(m);
		rep(j, m) cin >> a[i][j];
	}
	return a;
}

template<typename First>
void out(First first) {
	cout << first << endl;
}

template<typename First, typename... Rest>
void out(First first, Rest... rest) {
	cout << first << " ";
	out(rest...);
}

template<class T, size_t n, size_t idx = 0>
auto make_vec(const size_t(&d)[n], const T& init) noexcept {
	if constexpr (idx < n) return std::vector(d[idx], make_vec<T, n, idx + 1>(d, init));
	else return init;
}

template<class T, size_t n>
auto make_vec(const size_t(&d)[n]) noexcept {
	return make_vec(d, T{});
}

bool is_bit_on(int b, int i) {
	return (b >> i) & 1;
}

template<typename X, typename Y>
vector<Y> python_map(function<Y(X)>f, vector<X>xs) {
	vector<Y> ys;
	for (X x : xs) {
		auto y = f(x);
		ys.push_back(y);
	}
	p_vector(ys);
	return ys;
};

struct Point {
	int y, x;
};

// end of template

int calc_dx(string d) {
	if (d == "R") return 1;
	if (d == "L") return -1;
	return 0;
}

int calc_dy(string d) {
	if (d == "U") return 1;
	if (d == "D") return -1;
	return 0;
}

bool is_yes() {
	int x1, y1; string d1; cin >> x1 >> y1 >> d1;
	int x2, y2; string d2; cin >> x2 >> y2 >> d2;
	// x1 + dx1 * a = x2 + dx2 * a
	// a * (dx1 - dx2) = x2 - x1
	// a = (x2 - x1) / (dx1 - dx2)
	// y1 + dy1 * a = y2 + dy2 * a
	// ey1 = y2 + dy2 * a - dy1 * a

	int dx1 = calc_dx(d1);
	int dy1 = calc_dy(d1);
	int dx2 = calc_dx(d2);
	int dy2 = calc_dy(d2);
	dump(dx1); dump(dy1); dump(dx2); dumpl(dy2);
	if (dx1 == dx2) {
		if (dx1 == 0) {
			return dy1 != dy2 && x1 == x2;
			// return dy1 != dy2 ;
		}
		return false;
	}
	int child = (dy2 - dy1) * (x2 - x1);
	int mother = dx1 - dx2;
	dump(child); dumpl(mother);
	//if (abs(child) % abs(mother) != 0) {
	//	return false;
	//}
	int a = math_div(child, mother);
	int ey1 = y2 * mother + child;
	dump(y1);  dumpl(ey1);
	return ey1 == y1 * mother;
}

void solve() {
	int t; cin >> t;
	rep(loop, t) {
		Yep(is_yes());
	}
}













signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	cout << fixed << setprecision(20);
	solve();
	return 0;
}

0