Submission #1126153

#TimeUsernameProblemLanguageResultExecution timeMemory
1126153HasanV11010238DEL13 (info1cup18_del13)C++20
0 / 100
12 ms840 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...