結果
| 問題 |
No.2519 Coins in Array
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-27 22:27:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,707 bytes |
| コンパイル時間 | 2,053 ms |
| コンパイル使用メモリ | 199,356 KB |
| 最終ジャッジ日時 | 2025-02-17 15:21:11 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 32 WA * 5 |
ソースコード
#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 ){
cout << 0 << endl << "1 2" << endl << "1 2" << endl;
}
else{
long long ans = 8e18,left = -1;
for(auto &a : A) a--;
for(int i=0; i<3; i++){
long long now = (A.at(i)*A.at((i+1)%3)-1)*(A.at((i+2)%3));
if(now < ans) ans = now,left = i;
}
if(ans < 0) ans = 0;
cout << ans << endl;
bool space = false;
for(int i=0; i<3; i++){
if(i == left) continue;
if(space) cout << " ";
cout << i+1; space = true;
}
cout << endl;
cout << "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--;
}
}
}