#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main(){
ll t;
cin>>t;
while (t--){
int n, k;
cin>>n>>k;
vector<int> v(k + 2, 0);
for (int i = 1; i <= k; i++){
cin>>v[i];
}
v[k + 1] = n + 1;
vector<int> ord;
for (int i = 0; i <= k; i++){
ord.push_back(v[i + 1] - v[i] - 1);
if (ord[i] != 0){
if (ord[i] % 2 == 0){
ord[i] = 2;
}
else{
ord[i] = 1;
}
}
}
bool can = 1;
for (int i = 0; i <= k; i++){
if (i == k && ord[i] != 0){
can = 0;
break;
}
else if (i == k){
continue;
}
if (i != k && ord[i] < 0){
can = 0;
}
else{
ord[i + 1] -= ord[i];
}
}
if (can){
cout<<0<<"\n";
cout<<"\n";
}
else{
cout<<-1<<"\n";
}
}
}
# | 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... |