#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define X first
#define Y second
#define pii pair<int,int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
for (; l != r; ++l)
cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x);
#else
#define test(x...) void(0);
#endif
const int N = 1001;
int main () {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector <int> a(m + 1, 0);
vector <int> rem;
for (int i = 1; i <= m; ++i) {
cin >> a[i];
rem.pb(a[i] - a[i - 1] - 1);
}
rem.pb(n - a[m]);
vector <int> move, fr;
int pre = 0;
bool fail = false;
for (int i = 1; i <= m; ++i) {
if (!rem[i - 1]) {
pre = 0;
continue;
}
if (rem[i - 1] & 1) {
// must 1
pre = 1;
rem[i - 1] -= pre, rem[i] -= pre;
move.pb(i - 1);
} else if (!pre) {
// must 2
pre = 2;
rem[i - 1] -= pre, rem[i] -= pre;
move.pb(i - 1), move.pb(i - 1);
} else {
pre = 0;
}
}
for (int i = 0; i <= m; ++i) if (rem[i] < 0)
fail = true;
if (fail || rem[m] & 1) {
cout << -1 << endl;
} else {
cout << 0 << endl;
cout << endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
8 ms |
316 KB |
Output isn't correct |
4 |
Incorrect |
8 ms |
204 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is partially correct |
2 |
Correct |
2 ms |
332 KB |
Output is partially 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 |
8 ms |
316 KB |
Output isn't correct |
4 |
Incorrect |
8 ms |
204 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
204 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 |
8 ms |
316 KB |
Output isn't correct |
4 |
Incorrect |
8 ms |
204 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
204 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 |
4 ms |
332 KB |
Output isn't correct |
9 |
Incorrect |
4 ms |
564 KB |
Output isn't correct |
10 |
Incorrect |
4 ms |
588 KB |
Output isn't correct |
11 |
Incorrect |
5 ms |
844 KB |
Output isn't correct |