提出 #67324535


ソースコード 拡げる

// Author: vrintle (Rahul Verma)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T> using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int int64_t
#define endl '\n'
#define sz(v) ((int) v.size())
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define pii pair<int, int>
#define inf 2e18
#define rep(n) for(int _ = 0; _ < n; _++)
#define loop(n, i) for(int i = 0; i < n; i++)
#define ff first
#define ss second
#define pb push_back
#define pc __builtin_popcountll

// Debug Template, copied from Mikel_Arteta_8 (https://codeforces.com/blog/entry/68809)
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef VRINTLE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// End of debugging template

int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x < y ? x : y; }

void solve() {
	int n;
	cin >> n;
	vi a(n);
	loop(n, i) {
		cin >> a[i];
	}
	sort(all(a), [&](auto& x, auto& y) {
		return abs(x) < abs(y);
	});
	if(abs(a[0]) == abs(a[n - 1])) {
		int pos = 0, neg = 0;
		loop(n, i) {
			if(a[i] > 0) pos++;
			else neg++;
		}
		return void(cout << (abs(pos - neg) < 2 || !pos || !neg ? "Yes" : "No"));
	}
	set<pii> s;
	for(int i = 0; i + 1 < n; i++) {
		int x = a[i + 1], y = a[i];
		int g = __gcd(x, y);
		x /= g;
		y /= g;
		if(x < 0) x *= -1, y *= -1;
		s.insert({x, y});
	}
	cout << (sz(s) == 1 ? "Yes" : "No");
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	cin >> t;
	while(t--) {
		solve();
		cout << endl;
	}
	return 0;
}

提出情報

提出日時
問題 D - Make Geometric Sequence
ユーザ BlindingKnight
言語 C++ 20 (gcc 12.2)
得点 425
コード長 2658 Byte
結果 AC
実行時間 69 ms
メモリ 15448 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 425 / 425
結果
AC × 1
AC × 32
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 02_handmade_31.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3396 KiB
01_random_01.txt AC 21 ms 3332 KiB
01_random_02.txt AC 62 ms 11920 KiB
01_random_03.txt AC 67 ms 14964 KiB
01_random_04.txt AC 42 ms 3528 KiB
01_random_05.txt AC 49 ms 7024 KiB
01_random_06.txt AC 12 ms 3456 KiB
01_random_07.txt AC 15 ms 4624 KiB
01_random_08.txt AC 42 ms 3468 KiB
01_random_09.txt AC 42 ms 3472 KiB
01_random_10.txt AC 24 ms 3492 KiB
01_random_11.txt AC 58 ms 10992 KiB
01_random_12.txt AC 42 ms 3612 KiB
01_random_13.txt AC 42 ms 3480 KiB
01_random_14.txt AC 42 ms 3448 KiB
01_random_15.txt AC 44 ms 4956 KiB
01_random_16.txt AC 42 ms 3424 KiB
01_random_17.txt AC 42 ms 3452 KiB
01_random_18.txt AC 32 ms 3448 KiB
01_random_19.txt AC 17 ms 4652 KiB
01_random_20.txt AC 20 ms 3616 KiB
01_random_21.txt AC 59 ms 11580 KiB
01_random_22.txt AC 42 ms 3388 KiB
01_random_23.txt AC 26 ms 3404 KiB
01_random_24.txt AC 69 ms 15448 KiB
01_random_25.txt AC 42 ms 3460 KiB
01_random_26.txt AC 42 ms 3484 KiB
01_random_27.txt AC 38 ms 5192 KiB
01_random_28.txt AC 58 ms 11580 KiB
01_random_29.txt AC 42 ms 3536 KiB
01_random_30.txt AC 24 ms 5152 KiB
02_handmade_31.txt AC 1 ms 3416 KiB