Language: C++

const int MAXN = 30;
int x[MAXN], y[MAXN], r[MAXN], c[MAXN];
bool ok[MAXN];
map<int, int> dp;

int square(int x) {return x*x;}

// i, j が重なってるかを調べる
// 重なってたら true
bool check(int i, int j) {
    int d2 = square(x[i]-x[j]) + square(y[i]-y[j]);
    return d2 < square(r[i]+r[j]);
}

int dfs(int state, int n) {
    int ret = 0;
    if (dp.find(state) != dp.end()) return dp[state];
    // まだ存在するやつで一番上にあるのを列挙
    vector<int> already;
    memset(ok, true, sizeof(ok));
    for (int i = 0; i < n; i++) {
        if ((state>>i)&1) continue;
        if (ok[i]) {
            already.push_back(i);
        }
        for (int j = i+1; j < n; j++) {
            if (check(i, j)) ok[j] = false;
        }
    }
    int sz = already.size();
    for (int i = 0; i < sz; i++) {
        for (int j = i+1; j < sz; j++) {
            int ai = already[i], aj = already[j];
            if (c[ai] == c[aj]) {
                int nstate = state;
                nstate |= 1<<ai;
                nstate |= 1<<aj;
                ret = max(2+dfs(nstate, n), ret);
            }
        }
    }
    return dp[state] = ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        if (n==0) break;
        for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i] >> c[i];
        dp.clear();
        cout << dfs(0, n) << endl;
    }
    return 0;
}


Compiler output:
a.cc:4:1: error: 'map' does not name a type
    4 | map<int, int> dp;
      | ^~~
a.cc: In function 'int dfs(int, int)':
a.cc:17:9: error: 'dp' was not declared in this scope
   17 |     if (dp.find(state) != dp.end()) return dp[state];
      |         ^~
a.cc:19:5: error: 'vector' was not declared in this scope
   19 |     vector<int> already;
      |     ^~~~~~
a.cc:19:12: error: expected primary-expression before 'int'
   19 |     vector<int> already;
      |            ^~~
a.cc:20:5: error: 'memset' was not declared in this scope
   20 |     memset(ok, true, sizeof(ok));
      |     ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | const int MAXN = 30;
a.cc:24:13: error: 'already' was not declared in this scope
   24 |             already.push_back(i);
      |             ^~~~~~~
a.cc:30:14: error: 'already' was not declared in this scope
   30 |     int sz = already.size();
      |              ^~~~~~~
a.cc:34:28: error: 'aj' was not declared in this scope; did you mean 'ai'?
   34 |             if (c[ai] == c[aj]) {
      |                            ^~
      |                            ai
a.cc:38:23: error: 'max' was not declared in this scope
   38 |                 ret = max(2+dfs(nstate, n), ret);
      |                       ^~~
a.cc:42:12: error: 'dp' was not declared in this scope
   42 |     return dp[state] = ret;
      |            ^~
a.cc: In function 'int main()':
a.cc:46:5: error: 'cin' was not declared in this scope
   46 |     cin.tie(0);
      |     ^~~
a.cc:47:5: error: 'ios' has not been declared
   47 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:52:9: error: 'dp' was not declared in this scope
   52 |         dp.clear();
      |         ^~
a.cc:53:9: error: 'cout' was not declared in this scope
   53 |         cout << dfs(0, n) << endl;
      |         ^~~~
a.cc:53:30: error: 'endl' was not declared in this scope
   53 |         cout << dfs(0, n) << endl;
      |                              ^~~~