답안 #96172

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96172 2019-02-06T17:08:13 Z alextodoran DEL13 (info1cup18_del13) C++14
15 / 100
13 ms 1656 KB
#include <bits/stdc++.h>

#define NM 100002

using namespace std;

int t;

int n, q;

int p[NM];
int x[NM], y[NM];

deque <int> op;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while(t--)
    {
        cin >> n >> q;
        for(int i = 1; i <= q; i++)
            cin >> p[i];
        p[q + 1] = n + 1;
        while(!op.empty())
            op.pop_front();
        for(int i = 0; i <= q; i++)
            x[i] = y[i] = p[i + 1] - p[i] - 1;
        for(int i = 1; i <= q; i++)
            while(x[i] && x[i - 1])
            {
                x[i]--;
                x[i - 1]--;
                op.push_back(p[i]);
            }
        for(int i = 0; i <= q; i++)
        {
            if(y[i] - x[i] == 0)
                continue;
            int mid = p[i] + (y[i] + 1) / 2;
            while(x[i] > 1)
            {
                op.push_front(mid);
                x[i] -= 2;
            }
        }
        bool ok = 1;
        for(int i = 0; i <= q; i++)
            if(x[i] > 0)
            {
                ok = 0;
                break;
            }
        if(ok)
        {
            cout << op.size() << "\n";
            while(!op.empty())
            {
                cout << op.front() << " ";
                op.pop_front();
            }
            cout << "\n";
        }
        else
            cout << "-1\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 380 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 380 KB Output isn't correct
3 Incorrect 7 ms 376 KB Output isn't correct
4 Incorrect 5 ms 504 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 632 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 380 KB Output isn't correct
3 Incorrect 7 ms 376 KB Output isn't correct
4 Incorrect 5 ms 504 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 380 KB Output isn't correct
3 Incorrect 7 ms 376 KB Output isn't correct
4 Incorrect 5 ms 504 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Incorrect 6 ms 760 KB Output isn't correct
9 Incorrect 9 ms 1068 KB Output isn't correct
10 Incorrect 7 ms 1016 KB Output isn't correct
11 Incorrect 13 ms 1656 KB Output isn't correct