답안 #921456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921456 2024-02-03T22:04:11 Z Ianis Football (info1cup20_football) C++17
50 / 100
26 ms 756 KB
#ifdef LOCAL
#include <iostream>
#include <fstream>
#include <iomanip>
#include <random>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#else
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#define cerr if (false) cerr 
#define endl '\n'
#endif
 
#define fi first
#define se second
 
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
 
#define lsb(x) (x & (-x))
 
#define bit(mask, i) (((mask) >> (i)) & 1)
#define popcount(x) __builtin_popcount(x)
 
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
 
using namespace std;
 
template <typename T>
bool ckmax(T &a, T b) { return a < b ? a = b, true : false; }
template <typename T>
bool ckmin(T &a, T b) { return a > b ? a = b, true : false; }
 
using ll = long long;
using pii = pair<int, int>;
 
const int NMAX = 1e5+5;
 
int n, k;
int a[NMAX];
ll sum;
 
void read() {
   cin >> n >> k;
   sum = 0;
   for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
   }
}
 
bool solve() {
   if (k == 1 || sum % 2 == 1)
     return sum % 2;
   
   int ans = 0;
   ll cnt = 0;

   for (int i = 1; i <= n; i++) {
      ans ^= a[i] % 2;
      cnt += a[i] / 2;
   }

   return ((ans != 0) + cnt) % 2;
}
 
signed main() {
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
#endif
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   int t = 1;
   cin >> t;
 
   while (t--) {
      read();
      cout << solve();
   }
 
   return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 348 KB Output is correct
2 Correct 9 ms 348 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 8 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 8 ms 484 KB Output is correct
3 Correct 8 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 756 KB Output isn't correct
2 Halted 0 ms 0 KB -