Submission #3778857
Source Code Expand
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
int N;
int M;
int A[114514];
vector<int> ms[2];
vector<int> ans;
int main() {
scanf("%d%d", &N, &M);
rep(i, M) {
scanf("%d", &A[i]);
ms[A[i]%2].eb(A[i]);
}
if (ms[1].size() > 2) {
puts("Impossible");
return 0;
}
if (M < 2) {
printf("%d\n", A[0]);
if (A[0] == 1) puts("1\n1");
else printf("2\n%d %d\n", 1, A[0]-1);
return 0;
}
while (ms[1].size() < 2) {
assert(!ms[0].empty());
ms[1].eb(ms[0].back());
ms[0].pop_back();
}
ans.eb(ms[1][0]+1);
for (int v : ms[0]) {
ans.eb(v);
}
if (ms[1][1] > 1) {
ans.eb(ms[1][1]-1);
}
printf("%d", ms[1][0]);
for (int v : ms[0]) {
printf(" %d", v);
}
printf(" %d\n", ms[1][1]);
printf("%d\n", (int)ans.size());
int K = ans.size();
rep(i, K) {
printf("%d%c", ans[i], " \n"[i == K-1]);
}
}
Submission Info
Submission Time |
|
Task |
D - Arrays and Palindrome |
User |
potetisensei |
Language |
C++14 (GCC 5.4.1) |
Score |
1000 |
Code Size |
1817 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:35:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &N, &M);
^
./Main.cpp:37:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &A[i]);
^
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, 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 |
AC |
1 ms |
256 KB |
01-07.txt |
AC |
1 ms |
256 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 |
AC |
1 ms |
256 KB |
01-17.txt |
AC |
1 ms |
256 KB |
01-18.txt |
AC |
1 ms |
256 KB |
01-19.txt |
AC |
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 |
AC |
1 ms |
256 KB |
01-24.txt |
AC |
1 ms |
256 KB |
01-25.txt |
AC |
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 |