結果

問題 No.2519 Coins in Array
ユーザー maeshunmaeshun
提出日時 2023-10-28 15:06:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,938 bytes
コンパイル時間 4,109 ms
コンパイル使用メモリ 241,920 KB
実行使用メモリ 5,992 KB
最終ジャッジ日時 2023-10-28 15:06:41
合計ジャッジ時間 11,268 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 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 AC 2 ms
4,348 KB
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 336 ms
5,992 KB
testcase_24 AC 326 ms
4,968 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 342 ms
5,600 KB
testcase_28 AC 339 ms
5,600 KB
testcase_29 AC 339 ms
5,600 KB
testcase_30 AC 298 ms
5,452 KB
testcase_31 AC 52 ms
4,348 KB
testcase_32 AC 160 ms
4,532 KB
testcase_33 AC 232 ms
5,128 KB
testcase_34 AC 110 ms
4,348 KB
testcase_35 AC 212 ms
4,772 KB
testcase_36 AC 88 ms
4,348 KB
testcase_37 AC 40 ms
4,348 KB
testcase_38 AC 175 ms
4,604 KB
testcase_39 AC 100 ms
4,348 KB
testcase_40 AC 312 ms
5,992 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:90:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   90 |             auto [r, i,j,k] = t[0];
      |                  ^

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <atcoder/all>
    using namespace atcoder;
    #define rep(i, n) for(int i=0;i<(n);++i)
    #define rep1(i, n) for(int i=1;i<=(n);i++)
    #define ll long long
    using mint = modint998244353;
    using P = pair<ll,ll>;
    using lb = long double;
    using T = tuple<ll, ll, ll>;
    #ifdef LOCAL
    #  include <debug_print.hpp>
    #  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
    #else
    #  define dbg(...) (static_cast<void>(0))
    #endif

    int main()
    {
        int n;
        cin >> n;
        vector<ll> a(n);
        rep(i,n) cin >> a[i];
        vector<int> vs;
        rep(i,n) if(a[i]%2==0) vs.push_back(i);
        if(vs.size()>=2){
            cout << 0 << endl;
            cout << vs[0] +1 << " " << vs[1] + 1 << endl;
            for(int j=n-1;j>=2;j--){
                cout << j << " " << 1 << endl;
            }
            return 0;
        }
        vector<int> odd;
        rep(i,n) if(a[i]%2) odd.push_back(i);
        if(odd.size()>=4){
            cout << 0 << endl;
            cout << odd[0]+1 << " " << odd[1] + 1 << endl;
            cout << odd[2] + 1 -2 << " " << odd[3] + 1 -2 << endl;
            for(int j=n-2;j>=2;j--){
                cout << j << " " << 1 << endl;
            }
            return 0;
        }
        if(odd.size()>=2 && vs.size()==1){
            cout << 0 << endl;
            cout << odd[0] + 1 << " " << odd[1] + 1 << endl;
            vector<int> v;
            rep(i,n){
                if(i==odd[0] || i==odd[1]){
                    continue;
                }
                v.push_back(a[i]);
            }
            rep(i,n-2){
                if(v[i]%2==0) {
                    cout << i + 1 << " " << n-1 << endl;
                    break;
                }
            }
            for(int j=n-2;j>=2;j--){
                cout << j << " " << 1 << endl;
            }
            return 0;
        }
        if(n==2){
            if(a[0]==1 || a[1]==1){
                cout << 1 << endl;
                cout << 1 << " " << 2 << endl;
                return 0;
            }
            cout << a[0]*a[1] - a[0] - a[1] + 1 << endl;
            cout << 1 << " " << 2 << endl;
        }
        if(n==3){
            vector<tuple<ll, int,int,int>> t;
            rep(i,n)rep(j,n)rep(k,n){
                if(i==j || j==k || k==i) continue;
                ll r = a[i] * a[j] + 1 - a[i] - a[j];
                r = r * a[k] + 1 - a[k] - r;
                t.emplace_back(r, i,j,k);
            }
            rep(i,n){
                if(a[i]==1){
                   t.emplace_back(1, i, (i+1)%n, 0);
                }
            }
            sort(t.begin(),t.end());
            auto [r, i,j,k] = t[0];
            cout << r << endl;
            cout << i+1 << " " << j +1 << endl;
            cout << 1 << " " << 2 << endl;
        }
        return 0;
    }
0