# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
317172 | casperwang | DEL13 (info1cup18_del13) | C++14 | 10 ms | 1280 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
vector <int> arr(n+2);
bool tf = 1;
for (int i = 1; i <= n; i++)
arr[i] = i;
arr[0] = arr[n+1] = 0;
for (int i = 0; i < k; i++) {
int a;
cin >> a;
arr[a] = 0;
}
if ((n - k) % 2) tf = 0;
int l = 1, r = 0;
vector <int> ans;
int cnt = 0;
int tmp = -1;
for (int i = 1; i <= n+1; i++) {
if (!arr[i]) {
if (!arr[r]) {
l = i+1;
continue;
}
if (cnt > r-l+1) {
tf = 0;
break;
}
int c = r-l+1;
if ((c-cnt) % 2) {
for (int j = 0; j < (c-cnt)/2; j++)
ans.pb((l+r)/2);
} else {
for (int j = (cnt!=2); j < (c-cnt)/2; j++)
ans.pb((l+r)/2);
}
if (cnt == 1) ans.pb(tmp);
if (cnt == 2) ans.pb(tmp), ans.pb(tmp);
if ((c-cnt) % 2) {
cnt = 1;
tmp = i;
} else if (!cnt && c % 2 == 0) {
cnt = 2;
tmp = i;
} else {
cnt = 0;
}
l = r = i+1;
} else r = i;
}
if (cnt) tf = 0;
if (!tf) {
cout << -1 << "\n";
} else {
cout << ans.size() << "\n";
if (!ans.size()) cout << "\n";
for (int i = 0; i < ans.size(); i++)
cout << ans[i] << " \n"[i==ans.size()-1];
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |