Submission #67371107


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define v vector
#define pb push_back
#define pf push_front
#define F first
#define S second
#define PI 3.14159265358979323846
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void fastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
void solve() {
  // Your solution here
  int t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    int neg = 0;
    int pos = 0;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] > 0)
        pos++;
      else
        neg++;
    }
    sort(a.begin(), a.end(), [&](ll i, ll j) { return (abs(i) < abs(j)); });
    int flag = 0;
    if (n > 2) {
      for (int i = 0; i < n - 2; i++) {
        if (a[i + 2] * a[i] != a[i + 1] * a[i + 1]) {
          flag = -1;
          break;
        }
      }
      if (pos != 0 && neg != 0) {
        for (int i = 0; i < n - 2; i++) {
          if (!((a[i] > 0 && a[i + 1] < 0 && a[i + 2] > 0) ||
                (a[i] < 0 && a[i + 1] > 0 && a[i + 2] < 0))) {
            flag = -1;
            break;
          }
        }
      }
    }
    if (flag == -1)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}

int main() {
  fastIO();

  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }

  return 0;
}

Submission Info

Submission Time
Task D - Make Geometric Sequence
User Coderpanda_420
Language C++ 20 (gcc 12.2)
Score 0
Code Size 1463 Byte
Status WA
Exec Time 25 ms
Memory 4592 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 425
Status
AC × 1
AC × 3
WA × 29
Set Name Test Cases
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
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3512 KiB
01_random_01.txt WA 9 ms 3524 KiB
01_random_02.txt WA 23 ms 4120 KiB
01_random_03.txt WA 25 ms 4444 KiB
01_random_04.txt WA 18 ms 3508 KiB
01_random_05.txt WA 20 ms 3652 KiB
01_random_06.txt WA 5 ms 3528 KiB
01_random_07.txt AC 14 ms 4592 KiB
01_random_08.txt WA 18 ms 3520 KiB
01_random_09.txt WA 18 ms 3520 KiB
01_random_10.txt WA 10 ms 3520 KiB
01_random_11.txt WA 22 ms 4032 KiB
01_random_12.txt WA 18 ms 3524 KiB
01_random_13.txt WA 18 ms 3528 KiB
01_random_14.txt WA 18 ms 3524 KiB
01_random_15.txt WA 18 ms 3512 KiB
01_random_16.txt WA 18 ms 3524 KiB
01_random_17.txt WA 18 ms 3520 KiB
01_random_18.txt WA 13 ms 3528 KiB
01_random_19.txt AC 15 ms 4588 KiB
01_random_20.txt WA 8 ms 3572 KiB
01_random_21.txt WA 23 ms 4120 KiB
01_random_22.txt WA 18 ms 3504 KiB
01_random_23.txt WA 11 ms 3576 KiB
01_random_24.txt WA 25 ms 4504 KiB
01_random_25.txt WA 18 ms 3576 KiB
01_random_26.txt WA 18 ms 3584 KiB
01_random_27.txt WA 16 ms 3516 KiB
01_random_28.txt WA 22 ms 4232 KiB
01_random_29.txt WA 18 ms 3524 KiB
01_random_30.txt WA 10 ms 3492 KiB
02_handmade_31.txt WA 1 ms 3568 KiB