提出 #67353610


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;

int main() {
    int T; cin >> T;
    rep(t, T){
        int N; cin >> N;
        vector<ll> A(N);
        vector<ll> A_abs(N);
        bool contain_p = 0;
        bool contain_m = 0;
        set<ll> A_data;

        rep(i, N){
            cin >> A[i];
            A_abs[i] = abs(A[i]);
            if(A[i]>0) contain_p = 1;
            if(A[i]<0) contain_m = 1;
            A_data.insert(A[i]);
        }

        bool contain_pm = contain_p && contain_m;

        sort(A.begin(), A.end());
        sort(A_abs.begin(), A_abs.end());

        bool ans = 1;

        for(int i=2; i<A_abs.size(); i++){
            if((__int128_t)A_abs[i]*A_abs[0] != (__int128_t)A_abs[i-1]*A_abs[1]){
                ans = 0;
                break;
            }
        }

        if(contain_pm){
            ll first = A_abs[0];
            bool is_first_plus = 1;

            if(A_data.count(first)) is_first_plus = 1;
            else if(A_data.count(first * -1)) is_first_plus = 0;
            
            if(is_first_plus){
                rep(i, N){
                    if(i%2==0){
                        if(!A_data.count(A_abs[i])){
                            ans = 0;
                            break;
                        }
                    }
                    else{
                        if(!A_data.count(A_abs[i] * -1)){
                            ans = 0;
                            break;
                        }
                    }
                }
            }
            else{
                rep(i, N){
                    if(i%2!=0){
                        if(!A_data.count(A_abs[i])){
                            ans = 0;
                            break;
                        }
                    }
                    else{
                        if(!A_data.count(A_abs[i] * -1)){
                            ans = 0;
                            break;
                        }
                    }
                }
            }
        }
        
        if(ans) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

提出情報

提出日時
問題 D - Make Geometric Sequence
ユーザ tsusu0409
言語 C++ 20 (gcc 12.2)
得点 0
コード長 2299 Byte
結果 WA
実行時間 160 ms
メモリ 14188 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:32:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   32 |         for(int i=2; i<A_abs.size(); i++){
      |                      ~^~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 425
結果
AC × 1
AC × 30
WA × 2
セット名 テストケース
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 3496 KiB
01_random_01.txt AC 47 ms 3412 KiB
01_random_02.txt AC 137 ms 10988 KiB
01_random_03.txt AC 159 ms 13424 KiB
01_random_04.txt AC 98 ms 3492 KiB
01_random_05.txt AC 105 ms 6700 KiB
01_random_06.txt AC 27 ms 3604 KiB
01_random_07.txt AC 59 ms 6308 KiB
01_random_08.txt AC 98 ms 3536 KiB
01_random_09.txt AC 98 ms 3500 KiB
01_random_10.txt AC 56 ms 3540 KiB
01_random_11.txt AC 123 ms 9944 KiB
01_random_12.txt AC 99 ms 3408 KiB
01_random_13.txt AC 98 ms 3560 KiB
01_random_14.txt AC 99 ms 3560 KiB
01_random_15.txt AC 101 ms 4668 KiB
01_random_16.txt AC 98 ms 3480 KiB
01_random_17.txt AC 98 ms 3536 KiB
01_random_18.txt AC 72 ms 3532 KiB
01_random_19.txt WA 61 ms 6228 KiB
01_random_20.txt AC 45 ms 3500 KiB
01_random_21.txt AC 130 ms 10520 KiB
01_random_22.txt AC 99 ms 3496 KiB
01_random_23.txt AC 60 ms 3500 KiB
01_random_24.txt AC 160 ms 14188 KiB
01_random_25.txt AC 99 ms 3476 KiB
01_random_26.txt AC 98 ms 3536 KiB
01_random_27.txt AC 83 ms 4944 KiB
01_random_28.txt AC 133 ms 10720 KiB
01_random_29.txt AC 98 ms 3476 KiB
01_random_30.txt AC 50 ms 4748 KiB
02_handmade_31.txt WA 1 ms 3528 KiB