Submission #2558370


Source Code Expand

#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MAXM = 105;

int A[MAXM];

int N, M;

int main() {
	cin >> N >> M;
	for(int i = 0; i < M; i++) cin >> A[i];
	if(1 == M) {
		cout << N << endl;
		if(1 == N) {
			cout << "1\n1" << endl;
		} else {
			cout << "2\n" << N-1 << " 1" << endl;
		}
	} else if(2 == M) {
		for(int i = 0; i < M; i++) cout << A[i] << " ";
		cout << endl;
		if(1 == A[0] || 1 == A[1]) {
			cout << "1\n" << N << endl;
		} else {
			cout << "2\n" << A[0]-1 << " " << A[1]+1 << endl;
		}
	} else {
		int c = 0;
		for(int i = 0; i < M; i++) c += (A[i]&1);
		if(1 < c) {
			puts("Impossible");
		} else {
			for(int i = 1; i < M; i++) if(A[i]&1) swap(A[0], A[i]);
			for(int i = 0; i < M; i++) cout << A[i] << " ";
			cout << endl;

			vector<int> V;
			V.pb(A[0]-1);
			for(int i = 1; i+1 < M; i++) V.pb(A[i]);
			V.pb(A[M-1]+1);

			{
				vector<int> Q;
				for(int v : V) if(v) Q.pb(v);
				swap(V, Q);
			}

			cout << sz(V) << endl;
			for(int v : V) cout << v << " ";
			cout << endl;
		}
	}
	return 0;
}

Submission Info

Submission Time
Task D - Arrays and Palindrome
User youngyojun
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2901 Byte
Status WA
Exec Time 2 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1000
Status
AC × 3
AC × 26
WA × 5
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, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt AC 1 ms 256 KB
01-02.txt AC 1 ms 256 KB
01-03.txt AC 1 ms 256 KB
01-04.txt AC 1 ms 256 KB
01-05.txt AC 1 ms 256 KB
01-06.txt WA 1 ms 256 KB
01-07.txt AC 2 ms 384 KB
01-08.txt AC 1 ms 256 KB
01-09.txt AC 1 ms 256 KB
01-10.txt AC 1 ms 256 KB
01-11.txt AC 1 ms 256 KB
01-12.txt AC 1 ms 256 KB
01-13.txt AC 1 ms 256 KB
01-14.txt AC 1 ms 256 KB
01-15.txt AC 1 ms 256 KB
01-16.txt WA 1 ms 256 KB
01-17.txt AC 1 ms 256 KB
01-18.txt AC 1 ms 256 KB
01-19.txt WA 1 ms 256 KB
01-20.txt AC 1 ms 256 KB
01-21.txt AC 1 ms 256 KB
01-22.txt AC 1 ms 256 KB
01-23.txt WA 1 ms 256 KB
01-24.txt AC 1 ms 256 KB
01-25.txt WA 1 ms 256 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB
sample-03.txt AC 1 ms 256 KB