답안 #84142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
84142 2018-11-13T12:54:59 Z alextodoran DEL13 (info1cup18_del13) C++14
15 / 100
12 ms 1676 KB
#include <bits/stdc++.h>

#define NM 100002

using namespace std;

int t;

int n, k;

int p[NM], d[NM], di[NM];

deque <int> op;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> t;
    while(t--)
    {
        cin >> n >> k;
        op.clear();
        p[0] = 0;
        p[k + 1] = n + 1;
        for(int i = 1; i <= k; i++)
            cin >> p[i];
        k++;
        for(int i = 1; i <= k; i++)
        {
            d[i] = p[i] - p[i - 1] - 1;
            di[i] = d[i];
        }
        for(int i = 1; i < k; i++)
        {
            int mi = min(d[i], d[i + 1]);
            for(int j = 1; j <= mi; j++)
                op.push_back(p[i]);
            d[i] -= mi;
            d[i + 1] -= mi;
        }
        bool ok = 1;
        for(int i = 1; i <= k; i++)
        {
            if(d[i] == 0 || (di[i] - d[i] > 0 && d[i] % 2 == 0))
            {
                for(int j = 1; j <= d[i] / 2; j++)
                    op.push_front(p[i - 1] + di[i] / 2 + 1);
                d[i] = 0;
            }
            else
            {
                ok = 0;
                break;
            }
        }
        if(ok == 0)
            cout << "-1\n";
        else
        {
            cout << op.size() << "\n";
            for(auto i : op)
                cout << i << " ";
            cout << "\n";
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 380 KB Output isn't correct
2 Incorrect 3 ms 380 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 380 KB Output isn't correct
2 Incorrect 3 ms 380 KB Output isn't correct
3 Incorrect 5 ms 460 KB Output isn't correct
4 Incorrect 6 ms 628 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 824 KB Output is correct
2 Correct 4 ms 824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 380 KB Output isn't correct
2 Incorrect 3 ms 380 KB Output isn't correct
3 Incorrect 5 ms 460 KB Output isn't correct
4 Incorrect 6 ms 628 KB Output isn't correct
5 Incorrect 2 ms 824 KB Output isn't correct
6 Incorrect 2 ms 824 KB Output isn't correct
7 Incorrect 2 ms 824 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 380 KB Output isn't correct
2 Incorrect 3 ms 380 KB Output isn't correct
3 Incorrect 5 ms 460 KB Output isn't correct
4 Incorrect 6 ms 628 KB Output isn't correct
5 Incorrect 2 ms 824 KB Output isn't correct
6 Incorrect 2 ms 824 KB Output isn't correct
7 Incorrect 2 ms 824 KB Output isn't correct
8 Incorrect 9 ms 908 KB Output isn't correct
9 Incorrect 9 ms 1164 KB Output isn't correct
10 Incorrect 8 ms 1164 KB Output isn't correct
11 Incorrect 12 ms 1676 KB Output isn't correct