Submission #1141488

#TimeUsernameProblemLanguageResultExecution timeMemory
1141488brianhdzmdoCoins (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;

vector<int> find_coin(vector<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;
}

vector<int> coin_flips(vector<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: In function 'std::vector<int> find_coin(std::vector<int>&)':
coins.cpp:58:16: error: could not convert 'pos_o' from 'int' to 'std::vector<int>'
   58 |         return pos_o;
      |                ^~~~~
      |                |
      |                int
coins.cpp:61:12: error: could not convert 'pos_z' from 'int' to 'std::vector<int>'
   61 |     return pos_z;
      |            ^~~~~
      |            |
      |            int
coins.cpp: In function 'std::vector<int> coin_flips(std::vector<int>&, int)':
coins.cpp:113:21: error: call of overloaded 'find_coin(std::vector<int>&)' is ambiguous
  113 |     return find_coin(b);
      |            ~~~~~~~~~^~~
In file included from coins.cpp:1:
coins.h:4:5: note: candidate: 'int find_coin(std::vector<int>)'
    4 | int find_coin(std::vector<int> b);
      |     ^~~~~~~~~
coins.cpp:38:13: note: candidate: 'std::vector<int> find_coin(std::vector<int>&)'
   38 | vector<int> find_coin(vector<int>& b)
      |             ^~~~~~~~~