WA了,求助
查看原帖
WA了,求助
670046
___w楼主2024/5/15 15:58

rt,WA 了 10 个点。

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define ll long long
#define space putchar(' ')
#define enter putchar('\n')
using namespace std;

typedef vector <int> vi;
typedef pair <int, int> pii;

inline int rd() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) f = c == '-' ? -1 : f, c = getchar(); while (isdigit(c)) x = (x<<3)+(x<<1)+(c^48), c = getchar(); return x*f; }
inline ll rdll() { ll x = 0, f = 1; char c = getchar(); while (!isdigit(c)) f = c == '-' ? -1 : f, c = getchar(); while (isdigit(c)) x = (x<<3)+(x<<1)+(c^48), c = getchar(); return x*f; }
template <typename T> inline void write(T x) { if (x < 0) x = -x, putchar('-'); if (x > 9) write(x/10); putchar(x%10+48); }

int main() {
	int n, m, idx, cnt = 0; cin >> n >> m;
	vi a(m+1), b(m+1); for (int i = 1; i <= m; ++i) cin >> a[i], cnt += a[i]&1;
	if (cnt >= 3) puts("Impossible"), exit(0);
	if (m == 1) {
		if (a[1] == 1) puts("1\n1\n1");
		else cout << n << "\n2\n1 " << n-1;
		exit(0);
	}
	sort(a.begin()+1, a.begin()+m+1, [](int x, int y) { return x&1 > y&1; });
	swap(a[2], a[m]);
	for (int i = 1; i <= m; ++i) cout << a[i] << ' ', b[i] = a[i]; enter;
	++b[1], --b[m]; if (!b[m]) --m; cout << m << '\n';
	for (int i = 1; i <= m; ++i) cout << b[i] << ' ';
	return 0;
}
2024/5/15 15:58
加载中...