結果

問題 No.2519 Coins in Array
ユーザー GOTKAKOGOTKAKO
提出日時 2023-10-27 22:39:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,708 bytes
コンパイル時間 2,144 ms
コンパイル使用メモリ 207,784 KB
実行使用メモリ 5,988 KB
最終ジャッジ日時 2023-10-27 22:39:31
合計ジャッジ時間 8,729 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 277 ms
5,900 KB
testcase_24 AC 281 ms
5,900 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 274 ms
5,904 KB
testcase_28 AC 271 ms
5,900 KB
testcase_29 AC 280 ms
5,988 KB
testcase_30 AC 246 ms
5,752 KB
testcase_31 AC 43 ms
4,348 KB
testcase_32 AC 133 ms
4,596 KB
testcase_33 AC 194 ms
5,512 KB
testcase_34 AC 92 ms
4,348 KB
testcase_35 AC 173 ms
5,032 KB
testcase_36 AC 73 ms
4,348 KB
testcase_37 AC 34 ms
4,348 KB
testcase_38 AC 150 ms
4,888 KB
testcase_39 AC 84 ms
4,348 KB
testcase_40 AC 272 ms
5,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<long long> A(N);
    for(auto &a : A) cin >> a;
    if(N == 2){
        bool zero = false;
        if(gcd(A.at(0),A.at(1)) != 1 || A.at(0) == 0 || A.at(1) == 0) cout << 0 << endl;
        else cout << (A.at(0)-1)*(A.at(1)-1) << endl;
        cout << "1 2" << endl;
    }
    else if(N == 3){
        if(A.at(0)%2 == 0 || A.at(1)%2 == 0 || A.at(2)%2 == 0 || *min_element(A.begin(),A.end()) == 1){
            cout << 0 << endl << "1 2" << endl << "1 2" << endl;
        }
        else{
            long long ans = 1,left = max_element(A.begin(),A.end())-A.begin();
            for(int i=0; i<3; i++){
                if(i == left) continue;
                ans *= A.at(i)-1;
            }
            ans = (ans-1)*(A.at(left)-1);
            cout << ans << endl;
            bool output = false;
            for(int i=0; i<3; i++){
                if(left == i) continue;
                if(output) cout << " ";
                output = true;
                cout << i+1;
            }  
            cout << endl << "1 2" << endl;
        }
    }
    else{
        cout << 0 << endl;
        vector<int> odd,even;
        for(int i=0; i<N; i++){
            if(A.at(i)%2) odd.push_back(i+1);
            else even.push_back(i+1); 
        }
        if(even.size() >= 2){
            cout << even.at(0) << " " << even.at(1) << endl;
            N -= 1;
        }
        else{
            cout << "1 2" << endl << "1 2" << endl;
            N -= 2;
        }

        while(N != 1){
            cout << "1 " << N << endl;
            N--; 
        }
    }
}
0