結果

問題 No.2564 衝突予測
ユーザー binapbinap
提出日時 2023-12-02 15:34:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 344 ms / 2,000 ms
コード長 2,242 bytes
コンパイル時間 4,539 ms
コンパイル使用メモリ 263,652 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 15:34:23
合計ジャッジ時間 8,557 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 314 ms
6,676 KB
testcase_04 AC 344 ms
6,676 KB
testcase_05 AC 314 ms
6,676 KB
testcase_06 AC 315 ms
6,676 KB
testcase_07 AC 344 ms
6,676 KB
testcase_08 AC 314 ms
6,676 KB
testcase_09 AC 313 ms
6,676 KB
testcase_10 AC 319 ms
6,676 KB
testcase_11 AC 314 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void solve()':
main.cpp:41:17: warning: 'z2' may be used uninitialized [-Wmaybe-uninitialized]
   41 |                 if(z2 == 0){
      |                 ^~
main.cpp:29:17: note: 'z2' was declared here
   29 |         int z1, z2;
      |                 ^~
main.cpp:62:20: warning: 'z1' may be used uninitialized [-Wmaybe-uninitialized]
   62 |         if(z1 == 2 or z1 == 3){
      |            ~~~~~~~~^~~~~~~~~~
main.cpp:29:13: note: 'z1' was declared here
   29 |         int z1, z2;
      |             ^~

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef long double ld;
typedef pair<int, int> P;

ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;}
template <int m> ostream& operator<<(ostream& os, const static_modint<m>& a) {os << a.val(); return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;}
template<typename U, typename T> ostream& operator<<(ostream& os, const pair<U, T>& p){os << p.first << ' ' << p.second; return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;}
template <typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;}

string t = "RLUD";

void solve(){
	pair<long long, long long> p1, p2;
	long long x1, y1, x2, y2;
	char c1, c2;
	cin >> p1.first >> p1.second >> c1;
	cin >> p2.first >> p2.second >> c2;
	int z1, z2;
	rep(i, 4){
		if(c1 == t[i]) z1 = i;
	}
	rep(i, 4){
		if(c2 == t[i]) z2 = i;
	}
	if(z1 == z2){
		cout << "No\n";
		return;
	}
	if(z1 + z2 == 1){
		if(z2 == 0){
			swap(p1, p2);
			swap(z1, z2);
		}
		if(p1.second == p2.second){
			if(p1.first < p2.first) cout << "Yes\n";
			else cout << "No\n";
		}else cout << "No\n";
		return;
	}
	if(z1 + z2 == 5){
		if(z2 == 2){
			swap(p1, p2);
			swap(z1, z2);
		}
		if(p1.first == p2.first){
			if(p1.second < p2.second) cout << "Yes\n";
			else cout << "No\n";
		}else cout << "No\n";
		return;
	}
	if(z1 == 2 or z1 == 3){
		swap(p1, p2);
		swap(z1, z2);
	}
	if(z1 == 1){
		p1.first *= -1;
		p2.first *= -1;
		z1 = 0;
	}
	if(z2 == 3){
		p1.second *= -1;
		p2.second *= -1;
		z2 = 2;
	}
	if(p1.first + p1.second == p2.first + p2.second){
		if(p1.first < p2.first) cout << "Yes\n";
		else cout << "No\n";
	}else cout << "No\n";
	return;
}

int main(){
	int t;
	cin >> t;
	rep(_, t) solve();
	
	return 0;
}
0