Submission #673225

# Submission time Handle Problem Language Result Execution time Memory
673225 2022-12-20T00:35:31 Z ThegeekKnight16 Jelly Flavours (IOI20_jelly) C++17
Compilation error
0 ms 0 KB
    #include "jelly.h"
    #include <bits/stdc++.h>
    using namespace std;
     
    const int MAXN = 2e3 + 10;
    const int MAXM = 1e4 + 10;
    const int INF = 0x3f3f3f3f;
     
    int dp[MAXN][MAXM];
    int dp2[MAXN][MAXM];
    int n, a[MAXN], b[MAXN];
    vector<pair<int, int> > buga;
     
    void limpar(int n, int m)
    {
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
              dp[i][j] = 0;
              dp2[i][j] = 0;
            }
        }
    }
     
    int find_maximum_unique(int x, int y, vector<int> _a, vector<int> _b) {
      n = _a.size();  
      //if (rand() % 2) {
        // swap(x, y);
        // swap(_a, _b);
      // }
     
      for (int i = 0; i < n; i++) 
        buga.emplace_back(_a[i], _b[i]);
     
      sort(buga.begin(), buga.end());
     
      for (int i = 1; i <= n; i++) {
        a[i] = buga[i - 1].first;
        b[i] = buga[i - 1].second;
      }
     
      for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= x; j++) {
          dp[i][j] = dp[i - 1][j];
     
          if (j >= a[i])
            dp[i][j] = max(dp[i][j], dp[i - 1][j - a[i]] + 1);
        }
      }
     
      for(int i = n, j = x; i >= 1; i--)
      {
          if (j >= a[i] && dp[i][j] == dp[i-1][j - a[i]] + 1) {
            j -= a[i]; b[i] = INF;
          }
      }
     
      for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= y; j++) {
          dp2[i][j] = dp2[i - 1][j];
     
          if (j >= b[i])
            dp2[i][j] = max(dp2[i][j], dp2[i - 1][j - b[i]] + 1);
        }
      }
     
      int resp = (dp[n][x] + dp2[n][y]);
     
      limpar(n, max(x, y));
      
      for (int i = 1; i <= n; i++) {
        a[i] = buga[i - 1].first;
        b[i] = buga[i - 1].second;
      }
     
      for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= y; j++) {
          dp[i][j] = dp[i - 1][j];
     
          if (j >= b[i])
            dp[i][j] = max(dp[i][j], dp[i - 1][j - b[i]] + 1);
        }
      }
     
      for(int i = n, j = x; i >= 1; i--)
      {
          if (j >= a[i] && dp[i][j] == dp[i-1][j - b[i]] + 1) {
            j -= b[i]; a[i] = INF;
          }
      }
     
      for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= x; j++) {
          dp2[i][j] = dp2[i - 1][j];
     
          if (j >= a[i])
            dp2[i][j] = max(dp2[i][j], dp2[i - 1][j - a[i]] + 1);
        }
      }
      
      return max(resp, dp2[n][x] + dp[n][y]);
    }

Compilation message

jelly.cpp:4:5: error: extended character   is not valid in an identifier
    4 |      
      |     ^
jelly.cpp:8:5: error: extended character   is not valid in an identifier
    8 |      
      |     ^
jelly.cpp:13:5: error: extended character   is not valid in an identifier
   13 |      
      |     ^
jelly.cpp:23:5: error: extended character   is not valid in an identifier
   23 |      
      |     ^
jelly.cpp:30:5: error: extended character   is not valid in an identifier
   30 |      
      |     ^
jelly.cpp:33:5: error: extended character   is not valid in an identifier
   33 |      
      |     ^
jelly.cpp:35:5: error: extended character   is not valid in an identifier
   35 |      
      |     ^
jelly.cpp:40:5: error: extended character   is not valid in an identifier
   40 |      
      |     ^
jelly.cpp:44:5: error: extended character   is not valid in an identifier
   44 |      
      |     ^
jelly.cpp:49:5: error: extended character   is not valid in an identifier
   49 |      
      |     ^
jelly.cpp:56:5: error: extended character   is not valid in an identifier
   56 |      
      |     ^
jelly.cpp:60:5: error: extended character   is not valid in an identifier
   60 |      
      |     ^
jelly.cpp:65:5: error: extended character   is not valid in an identifier
   65 |      
      |     ^
jelly.cpp:67:5: error: extended character   is not valid in an identifier
   67 |      
      |     ^
jelly.cpp:74:5: error: extended character   is not valid in an identifier
   74 |      
      |     ^
jelly.cpp:78:5: error: extended character   is not valid in an identifier
   78 |      
      |     ^
jelly.cpp:83:5: error: extended character   is not valid in an identifier
   83 |      
      |     ^
jelly.cpp:90:5: error: extended character   is not valid in an identifier
   90 |      
      |     ^
jelly.cpp:94:5: error: extended character   is not valid in an identifier
   94 |      
      |     ^
jelly.cpp:4:5: error: '\U000000a0' does not name a type
    4 |      
      |     ^
jelly.cpp:8:5: error: '\U000000a0' does not name a type
    8 |      
      |     ^
jelly.cpp:10:13: error: 'MAXN' was not declared in this scope; did you mean 'MAXM'?
   10 |     int dp2[MAXN][MAXM];
      |             ^~~~
      |             MAXM
jelly.cpp:11:14: error: 'MAXN' was not declared in this scope; did you mean 'MAXM'?
   11 |     int n, a[MAXN], b[MAXN];
      |              ^~~~
      |              MAXM
jelly.cpp:11:23: error: 'MAXN' was not declared in this scope; did you mean 'MAXM'?
   11 |     int n, a[MAXN], b[MAXN];
      |                       ^~~~
      |                       MAXM
jelly.cpp:13:5: error: '\U000000a0' does not name a type
   13 |      
      |     ^
jelly.cpp:23:5: error: '\U000000a0' does not name a type
   23 |      
      |     ^