Submission #1112809

#TimeUsernameProblemLanguageResultExecution timeMemory
1112809julia_08Coins (IOI17_coins)C++17
Compilation error
0 ms0 KiB
#include "coins.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> coin_flips(vector<int> b, int c){
  vector<int> flips;

  int x = 0;

  int pos = 0;

  for(int i=0; i<(int) b.size(); i++){
    if(b[i] == 1) x ^= pos;

    pos ++;
  }

  flips.push_back(x ^ c);

  return flips;
}

int find_coin(vector<int> b){

  int coin = 0;

  int pos = 0;

  for(int i=0; i<(int) b.size(); i++){
    if(b[i] == 1) x ^= pos;

    pos ++;
  }

  return coin;
}

Compilation message (stderr)

coins.cpp: In function 'int find_coin(std::vector<int>)':
coins.cpp:30:19: error: 'x' was not declared in this scope
   30 |     if(b[i] == 1) x ^= pos;
      |                   ^