Submission #364977

#TimeUsernameProblemLanguageResultExecution timeMemory
364977Matteo_VerzFootball (info1cup20_football)C++17
100 / 100
54 ms2048 KiB
/*
                `-/oo+/-   ``
              .oyhhhhhhyo.`od
             +hhhhyyoooos. h/
            +hhyso++oosy- /s
           .yoooossyyo:``-y`
            ..----.` ``.-/+:.`
                   `````..-::/.
                  `..```.-::///`
                 `-.....--::::/:
                `.......--::////:
               `...`....---:::://:
             `......``..--:::::///:`
            `---.......--:::::////+/`
            ----------::::::/::///++:
            ----:---:::::///////////:`
            .----::::::////////////:-`
            `----::::::::::/::::::::-
             `.-----:::::::::::::::-
               ...----:::::::::/:-`
                 `.---::/+osss+:`
                   ``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <random>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#define debug(x) cerr << #x << " " << x << '\n'
#define debugsp(x) cerr << #x << " " << x << ' '
 
using namespace std;
 
const int INF = 2e9;
const int N = 1e5;
 
int v[1 + N];
 
int answer;
void Solve(int n, int k) {
  int s(0);
  for(int i = 1; i <= n; i++)
    s ^= (v[i] & 1);
  if(k == 1) {
    answer = s;
    return;
  }
  if(s & 1) {
    answer = 1;
    return;
  }
  
  for(int i = 1; i <= n; i++)
    v[i] >>= 1;
  Solve(n, k >> 1);
}
 
int main() {
  int t;
  scanf("%d", &t);
 
  while(t--) {
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++) scanf("%d", &v[i]);
    Solve(n, k);
    printf("%d", answer); 
    answer = 0;
  }
  return 0;
}

Compilation message (stderr)

football.cpp: In function 'int main()':
football.cpp:68:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   68 |   scanf("%d", &t);
      |   ~~~~~^~~~~~~~~~
football.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   72 |     scanf("%d%d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~
football.cpp:73:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   73 |     for(int i = 1; i <= n; i++) scanf("%d", &v[i]);
      |                                 ~~~~~^~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...