Submission #1141486

#TimeUsernameProblemLanguageResultExecution timeMemory
1141486brianhdzmdoCoins (IOI17_coins)C++20
Compilation error
0 ms0 KiB
#include "coins.h"
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <string>
#include <set>
#include <utility>
#define all(a) (a).begin(), (a).end()
#define allr(a) (a).rbegin(), (a).rend()
#define ll long long
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, a, b) for (ll i = a - 1; i >= b; i--)
#define fi first
#define se second
#define mp(j, k) make_pair(j, k)
#define pb(x) push_back(x)
#define pbp(x, y) push_back({x, y})
#define in(x) insert(x)
#define vec vector<ll>
#define vecv vector<vector<ll> >
#define veb vector<bool>
#define vecp vector<pair<ll,ll>>
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define ac 1e-7
#define fauto(a)   \
  for (auto i : a) \
    cout << i << " ";
#define fautop(a)  \
  for (auto i : a) \
    cout << i.fi << " " << i.se << endl;

using namespace std;

int find_coin(int[] b)
{
    int one = 0, zero = 0;
    int pos_o = -1, pos_z = -1;

    fr(i, 0, 3)
    {
        if(b[i]){
            one++;
            pos_o = i;
        }
        else
        {
            zero++;
            pos_z = i;
        }
    }

    if(one == 1)
    {
        return pos_o;
    }
    else
    return pos_z;
}

int[] coin_flips(int[] b, int c)
{

    if(c == 1)
    {
        if(b[c] == b[c - 1] && b[c] == b[c + 1])
        {
            b[c] -= b[c] - 1;
        }
        else if(b[c] == b[c -1] && b[c] != b[c + 1])
        {
            b[c - 1] -= b[c - 1] - 1;
        }
        else if(b[c] != b[c - 1] && b[c] == b[c + 1])
        {
            b[c + 1] -= b[c + 1] - 1;
        }
    }
    else if(c == 0)
    {
        if(b[c] == b[c + 1] && b[c] == b[c + 2])
        {
            b[c] -= b[c] - 1;
        }
        else if(b[c] == b[c + 1] && b[c] != b[c + 2])
        {
            b[c + 1] -= b[c + 1] - 1;
        }
        else if(b[c] != b[c + 1] && b[c] == b[c + 2])
        {
            b[c + 2] -= b[c + 2] - 1;
        }
    }
    else if(c == 2)
    {
        if(b[c] == b[c - 1] && b[c] == b[c - 2])
        {
            b[c] -= b[c] - 1;
        }
        else if(b[c] == b[c - 1] && b[c] != b[c - 2])
        {
            b[c - 1] -= b[c - 1] - 1;
        }
        else if(b[c] != b[c - 1] && b[c] == b[c - 2])
        {
            b[c - 2] -= b[c - 2] - 1;
        } 
    }

    return find_coin(b);
}

Compilation message (stderr)

coins.cpp:38:21: error: expected ',' or '...' before 'b'
   38 | int find_coin(int[] b)
      |                     ^
coins.cpp: In function 'int find_coin(int*)':
coins.cpp:45:12: error: 'b' was not declared in this scope
   45 |         if(b[i]){
      |            ^
coins.cpp: At global scope:
coins.cpp:64:4: error: structured binding declaration cannot have type 'int'
   64 | int[] coin_flips(int[] b, int c)
      |    ^~
coins.cpp:64:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
coins.cpp:64:4: error: empty structured binding declaration
coins.cpp:64:7: error: expected initializer before 'coin_flips'
   64 | int[] coin_flips(int[] b, int c)
      |       ^~~~~~~~~~