Submission #494752

# Submission time Handle Problem Language Result Execution time Memory
494752 2021-12-16T05:27:15 Z syl123456 DEL13 (info1cup18_del13) C++17
0 / 100
11 ms 1416 KB
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wparentheses"
#include <bits/stdc++.h>
#define all(i) (i).begin(), (i).end()
#define random random_device rd; mt19937 rng(rd())
using namespace std;
template<typename T1, typename T2>
ostream& operator << (ostream &i, pair<T1, T2> j) {
    return i << j.first << ' ' << j.second;
}
template<typename T>
ostream& operator << (ostream &i, vector<T> j) {
    i << '{' << j.size() << ':';
    for (T ii : j) i << ' ' << ii;
    return i << '}';
}
void Debug(bool _split) {}
template<typename T1, typename ...T2>
void Debug(bool _split, T1 x, T2 ...args) {
    if (_split)
        cerr << ", ";
    cerr << x, Debug(true, args...);
}
template<typename T>
void Debuga(T *i, int n) {
    cerr << '[';
    for (int j = 0; j < n; ++j) cerr << i[j] << " ]"[j == n - 1];
    cerr << endl;
}
#ifdef SYL
#define debug(args...) cerr << "Line(" << __LINE__ << ") -> [" << #args << "] is [", Debug(false, args), cerr << ']' << endl
#define debuga(i) cerr << "Line(" << __LINE__ << ") -> [" << #i << "] is ", Debuga(i, sizeof(i) / sizeof(typeid(*i).name()))
#else
#define debug(args...) void(0)
#define debuga(i) void(0)
#endif
typedef long long ll;
typedef pair<int, int> pi;
const int inf = 0x3f3f3f3f, lg = 20;
const ll mod = 1e9 + 7, INF = 0x3f3f3f3f3f3f3f3f;

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        int a[m + 1];
        for (int i = 0; i < m; ++i)
            cin >> a[i], --a[i];
        a[m] = n;
        if (n == m)
            cout << "0\n\n";
        if (!m || n - m & 1) {
            cout << "-1\n";
            continue;
        }
        ++m;
        bool is[m], is2[m], fail = false;
        is[0] = a[0] == 0;
        is2[0] = !is[0] && ~a[0] & 1;
        for (int i = 1; i < m; ++i) {
            int x = a[i] - 1 - a[i - 1];
            is[i] = is2[i] = false;
            if (!is[i - 1] && !is2[i - 1]) {
                if (!x) {
                    fail = true;
                    break;
                }
                if (x & 1)
                    is[i] = true;
                if (x > 1 && x & 1)
                    is2[i] = true;
            }
            if (is[i - 1]) {
                if (!x)
                    is[i] = true;
                else if (~x & 1)
                    is2[i] = true;
            }
            if (is2[i - 1]) {
                if (x && ~x & 1)
                    is[i] = true;
                if (x > 2 && ~x & 1)
                    is2[i] = true;
            }
            if (!is[i - 1] && is2[i - 1]) {
                if (x < 2) {
                    fail = true;
                    break;
                }
            }
        }
        if (fail || !is[m - 1]) {
            cout << "-1\n";
            continue;
        }
        cout << (n - m + 1 >> 1) << '\n';
        int cnt[m];
        cnt[m - 1] = 0;
        for (int i = m - 1; i; --i) {
            int x = a[i] - 1 - a[i - 1];
            if (!cnt[i]) {
                if (!x)
                    cnt[i - 1] = 0;
                else
                    cnt[i - 1] = x & 1 ? 1 : 2;
            }
            else {
                x -= cnt[i];
                if (is[i - 1])
                    cnt[i - 1] = 0;
                else
                    cnt[i - 1] = x & 1 ? 1 : 2;
            }
        }
        for (int i = 0; i < m; ++i) {
            int x = i ? a[i - 1] + 3 : 2;
            int tmp = a[i] - 1 - (i ? a[i - 1] : -1);
            tmp -= cnt[i] + (i ? cnt[i - 1] : 0);
            for (int j = 0; j < tmp >> 1; ++j)
                cout << x << ' ', x += 2;
        }
        for (int i = 0; i < m; ++i)
            for (int j = 0; j < cnt[i]; ++j)
                cout << a[i] + 1 << ' ';
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 452 KB Output isn't correct
2 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Incorrect 1 ms 204 KB Output isn't correct
8 Correct 6 ms 612 KB Output is correct
9 Correct 6 ms 844 KB Output is correct
10 Incorrect 5 ms 760 KB Integer 88 violates the range [1, 87]
11 Correct 11 ms 1416 KB Output is correct