Language: C++


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class Deck
{
public:
  int start, end;
  Deck(int s, int e)
  {
    start = s;
    end = e;
  }

  vector<Deck> divide(int a, int b = -1)
  {
    vector<Deck> v;
    v.push_back(Deck(start, a));
    if(b == -1)
      v.push_back(Deck(a   1, end));
    else
      v.push_back(Deck(a   1, b));
      v.push_back(Deck(b   1, end));
    return v;
  }

  int get_ans(int n, int p, int q, int r)
  {
    int s = max(n, p);
    int res = min(min(q - s   1, end - start   n - s   1), r - start);
    if(res < 0)
      res = 0;
    cout << start << " " << end << ":" << s << " " << res << endl;
    return res;
  }

  int size()
  {
    return end - start   1;
  }
};

int main()
{
  vector<Deck> vp;
  vector<Deck> *v = 

Compiler output:
a.cc: In member function 'std::vector<Deck> Deck::divide(int, int)':
a.cc:22:23: error: expected primary-expression before '(' token
   22 |       v.push_back(Deck(a   1, end));
      |                       ^
a.cc:22:28: error: expected ')' before numeric constant
   22 |       v.push_back(Deck(a   1, end));
      |                            ^
a.cc:22:23: note: to match this '('
   22 |       v.push_back(Deck(a   1, end));
      |                       ^
a.cc:24:23: error: expected primary-expression before '(' token
   24 |       v.push_back(Deck(a   1, b));
      |                       ^
a.cc:24:28: error: expected ')' before numeric constant
   24 |       v.push_back(Deck(a   1, b));
      |                            ^
a.cc:24:23: note: to match this '('
   24 |       v.push_back(Deck(a   1, b));
      |                       ^
a.cc:25:23: error: expected primary-expression before '(' token
   25 |       v.push_back(Deck(b   1, end));
      |                       ^
a.cc:25:28: error: expected ')' before numeric constant
   25 |       v.push_back(Deck(b   1, end));
      |                            ^
a.cc:25:23: note: to match this '('
   25 |       v.push_back(Deck(b   1, end));
      |                       ^
a.cc: In member function 'int Deck::get_ans(int, int, int, int)':
a.cc:32:31: error: expected ')' before numeric constant
   32 |     int res = min(min(q - s   1, end - start   n - s   1), r - start);
      |                               ^
a.cc:32:22: note: to match this '('
   32 |     int res = min(min(q - s   1, end - start   n - s   1), r - start);
      |                      ^
a.cc:32:48: error: expected ')' before 'n'
   32 |     int res = min(min(q - s   1, end - start   n - s   1), r - start);
      |                                                ^
a.cc:32:22: note: to match this '('
   32 |     int res = min(min(q - s   1, end - start   n - s   1), r - start);
      |                      ^
a.cc: In member function 'int Deck::size()':
a.cc:41:26: error: expected ';' before numeric constant
   41 |     return end - start   1;
      |                          ^
a.cc: In function 'int main()':
a.cc:48:20: error: expected primary-expression at end of input
   48 |   vector<Deck> *v =
      |                    ^
a.cc:48:20: error: expected '}' at end of input
a.cc:46:1: note: to match this '{'
   46 | {
      | ^