답안 #47144

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47144 2018-04-28T06:24:27 Z Kmcode DEL13 (info1cup18_del13) C++14
0 / 100
10 ms 1176 KB
#include "bits/stdc++.h"
using namespace std;

#define MAX 100002

int n;

vector<int> v;
int q;

vector<pair<int, int> > vv;


bool ng;

vector<int> ope;
vector<int> v2;
void er() {
	v2.clear();
	int las = 0;
	for (int i = 0; i < vv.size(); i++) {
		int L = vv[i].first;
		int R = vv[i].second;
		int z = 0;
		while (las--&&L<=R) {
			R--;
			ope.push_back(L - 1);
			z++;
		}
		if (las!=-1) {
			ng = true;
			break;
		}
		if (R - L +1 > 2) {
			if ((R - L + 1) % 2) {
				
			}
			else {
				R--;
			}
		}
		int mid = (R + L) / 2;
		while (R - L + 1 > 2) {
			ope.push_back(mid);
			R--;
			L++;
			z += 2;
		}
		int rng = vv[i].second - vv[i].first;
		rng++;
		rng -= z;
		las = rng;
	}
	if (las) {
		ng = true;
	}
	vv.clear();
}

int main() {
	int t;
	cin >> t;
	while (t--) {
		ope.clear();
		ng = false;
		scanf("%d%d", &n,&q);
		v.clear();
		v.push_back(0);
		for (int i = 0; i < q; i++) {
			int a;
			scanf("%d", &a);
			v.push_back(a);
		}
		v.push_back(n+1);
		v.push_back(n + 2);
		for (int i = 1; i < v.size(); i++) {
			if (v[i] - v[i - 1] - 1 == 0) {
				er();
				continue;
			}
			vv.push_back(make_pair(v[i - 1] + 1, v[i] - 1));
		}
		if (ng) {
			puts("-1");
		}
		else {
			cout << ope.size() << endl;
			bool out = false;
			for (int el : ope) {
				if (out) {
					printf(" ");
				}
				out = true;
				printf("%d", el);
			}
			puts("");
		}
	}

	return 0;
}

Compilation message

del13.cpp: In function 'void er()':
del13.cpp:21:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < vv.size(); i++) {
                  ~~^~~~~~~~~~~
del13.cpp: In function 'int main()':
del13.cpp:76:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 1; i < v.size(); i++) {
                   ~~^~~~~~~~~~
del13.cpp:66:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n,&q);
   ~~~~~^~~~~~~~~~~~~~~
del13.cpp:71:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &a);
    ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Incorrect 3 ms 484 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Incorrect 3 ms 484 KB Output isn't correct
3 Incorrect 7 ms 540 KB Output isn't correct
4 Incorrect 9 ms 540 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 540 KB Output isn't correct
2 Incorrect 4 ms 984 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Incorrect 3 ms 484 KB Output isn't correct
3 Incorrect 7 ms 540 KB Output isn't correct
4 Incorrect 9 ms 540 KB Output isn't correct
5 Incorrect 2 ms 984 KB Output isn't correct
6 Incorrect 2 ms 984 KB Output isn't correct
7 Incorrect 2 ms 984 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Incorrect 3 ms 484 KB Output isn't correct
3 Incorrect 7 ms 540 KB Output isn't correct
4 Incorrect 9 ms 540 KB Output isn't correct
5 Incorrect 2 ms 984 KB Output isn't correct
6 Incorrect 2 ms 984 KB Output isn't correct
7 Incorrect 2 ms 984 KB Output isn't correct
8 Incorrect 9 ms 1004 KB Output isn't correct
9 Incorrect 10 ms 1176 KB Output isn't correct
10 Incorrect 10 ms 1176 KB Output isn't correct
11 Incorrect 9 ms 1176 KB Output isn't correct