이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
int t;
cin >> t;
while (t--){
int n, k, x;
cin >> n >> k;
if (k == 1){
ll sum = 0;
for (int i = 0; i<n; i++){
cin >> x;
sum += x;
}
cout << (sum%2 == 0 ? "0" : "1");
} else if (n == 1){
cin >> n;
if (k>=n){
if (n%2 == 0) cout << "1";
} else{
//cout << "here\n";
vector<bool> dp;
bool good = false;
if (n%2 != 0){
cout << "1";
continue;
}
for (int i = 2; i<=k; i++){
dp.assign(n+1, true);
//cout << "i= " << i << "\n";
for (int j = n-1; j>=1;j-=(i+1)){
//cout << j << "\n";
dp[j] = false;
}
//cout << "----------\n";
if (dp[1]){
good = true;
break;
}
}
cout << good;
}
} else{
cout << "0";
}
}
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |