답안 #464930

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464930 2021-08-14T13:29:07 Z hhhhaura DEL13 (info1cup18_del13) C++14
0 / 100
7 ms 2120 KB
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))

using namespace std;

#define INF 1000000000000000000
#define int long long int
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

#ifdef wiwihorz
#define print(a...) cerr << "Line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);} 
#else
#define print(...) 0
#define vprint(...) 0
#endif
namespace solver {
	int n, m;
	vector<int> a, b, ans;
	vector<pii> seg;
	void init_(int _n, int _m) {
		n = _n, m = _m;
		a.assign(m + 2, 0);
		b.assign(m + 2, 0);
		seg.assign(m + 2, {0, 0});
		ans.clear();
	}
	void solve() {
		a[m + 1] = n + 1;
		rep(i, 1, m + 1) {
			int L = a[i - 1] + 1, R = a[i] - 1;
			b[i] = (R - L + 1);
			seg[i] = {L, R};
		} 
		rep(i, 1, m) {
			int L = b[i], R = b[i + 1];
			if(L > 2) {
				int mid = (seg[i].first + seg[i].second) / 2;
				rep(j, 1, (L - 1) / 2) {
					b[i] -= 2;
					ans.push_back(mid);
				}
				L = b[i];
			}
			rep(j, 1, min(L, R)) {
				ans.push_back(a[i]);
				b[i] -= 1;
				b[i + 1] -= 1;
				seg[i + 1].first ++;
			}
			if(b[i]) {
				cout << "-1\n";
				return;
			}
		}
		if(b[m + 1]) {
			cout << "-1\n";
			return;
		}
		cout << "0\n";
		return ;
		cout << ans.size() << "\n";
		rep(i, 0, signed(ans.size()) - 1) 
			cout << ans[i] << " \n"[i + 1 == ans.size()];
		return;
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int t; cin >> t;
	while(t--) {
		int n, m;
		cin >> n >> m;
		init_(n, m);
		rep(i, 1, m) cin >> a[i];
		solve();
	}
	return 0;
}  

Compilation message

del13.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
del13.cpp:20:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
del13.cpp:20:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
del13.cpp: In function 'void solver::solve()':
del13.cpp:74:34: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |    cout << ans[i] << " \n"[i + 1 == ans.size()];
      |                            ~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Incorrect 3 ms 204 KB Output isn't correct
4 Incorrect 3 ms 204 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Incorrect 2 ms 968 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Incorrect 3 ms 204 KB Output isn't correct
4 Incorrect 3 ms 204 KB Output isn't correct
5 Incorrect 1 ms 332 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Incorrect 3 ms 204 KB Output isn't correct
4 Incorrect 3 ms 204 KB Output isn't correct
5 Incorrect 1 ms 332 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 Incorrect 6 ms 1096 KB Output isn't correct
9 Incorrect 7 ms 1832 KB Output isn't correct
10 Incorrect 6 ms 1996 KB Output isn't correct
11 Incorrect 6 ms 2120 KB Output isn't correct