Submission #811778
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int n,m;
const int maxn=1e5+10;
int a[maxn],b[maxn];
int main(){
cin>>n>>m;
int f=0;
for(int i=1;i<=m;i++){
cin>>a[i];
if(a[i]%2){
f++;
}
}
if(f>2){
cout<<"Impossible";
return 0;
}
int p=0;
if(m==1){
if(a[1]!=1){
b[++p]=a[1]-1;
}
b[++p]=1;
}
else if(m==2){
if(a[1]!=1){
b[++p]=a[1]-1;
}
b[++p]=a[2]+1;
}else{
int k=1;
for(int i=1;i<m;i++){
if(a[i]%2==1){
if(k==1){
swap(a[i],a[1]);
}
else swap(a[i],a[m]);
k++;
}
}
for(int i=1;i<=m;i++){
if(i==1){
if(a[i]-1!=0){
b[++p]=a[i]-1;
}
}
else {
b[++p]=a[i];
}
}
b[p]++;
}
for(int i=1;i<=m;i++){
cout<<a[i];
if(i!=m) cout<<" ";
else cout<<endl;
}
cout<<p<<endl;
for(int i=1;i<=p;i++){
cout<<b[i];
if(i!=p) cout<<" ";
else cout<<endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Arrays and Palindrome |
| User | kimnoic |
| Language | C++14 (GCC 5.4.1) |
| Score | 1000 |
| Code Size | 1319 Byte |
| Status | AC |
| Exec Time | 4 ms |
| Memory | 256 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | AC | 4 ms | 256 KiB |
| 01-02.txt | AC | 4 ms | 256 KiB |
| 01-03.txt | AC | 4 ms | 256 KiB |
| 01-04.txt | AC | 4 ms | 256 KiB |
| 01-05.txt | AC | 4 ms | 256 KiB |
| 01-06.txt | AC | 4 ms | 256 KiB |
| 01-07.txt | AC | 4 ms | 256 KiB |
| 01-08.txt | AC | 4 ms | 256 KiB |
| 01-09.txt | AC | 4 ms | 256 KiB |
| 01-10.txt | AC | 4 ms | 256 KiB |
| 01-11.txt | AC | 4 ms | 256 KiB |
| 01-12.txt | AC | 4 ms | 256 KiB |
| 01-13.txt | AC | 4 ms | 256 KiB |
| 01-14.txt | AC | 4 ms | 256 KiB |
| 01-15.txt | AC | 4 ms | 256 KiB |
| 01-16.txt | AC | 4 ms | 256 KiB |
| 01-17.txt | AC | 4 ms | 256 KiB |
| 01-18.txt | AC | 4 ms | 256 KiB |
| 01-19.txt | AC | 4 ms | 256 KiB |
| 01-20.txt | AC | 4 ms | 256 KiB |
| 01-21.txt | AC | 4 ms | 256 KiB |
| 01-22.txt | AC | 4 ms | 256 KiB |
| 01-23.txt | AC | 4 ms | 256 KiB |
| 01-24.txt | AC | 4 ms | 256 KiB |
| 01-25.txt | AC | 4 ms | 256 KiB |
| sample-01.txt | AC | 4 ms | 256 KiB |
| sample-02.txt | AC | 4 ms | 256 KiB |
| sample-03.txt | AC | 4 ms | 256 KiB |