Submission #1296006

#TimeUsernameProblemLanguageResultExecution timeMemory
1296006lukaye_19Packing Biscuits (IOI20_biscuits)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

long long count_tastiness(long long x, long long []a)
{
  long long k = sizeof(a) / sizeof(a[0]);
  
  long long totaltastiness = 0;
  long long returnvalue = 0;
  
  for (long long i = 0; i < k; i++)
  {
    long long totalcookies = a[i];
    
    totaltastiness += pow(2,i) * totalcookies;
  }
  
  for (long long i = 0; i < totaltastiness / x + 1; i++)
  {
    unordered_set<int>usedcookies;
    bool validtastevalue = true;
    
    for (long long j = 0; j < x; j++)
    {
      for (long long n = 0; n < pow(2,k); n++)
      {
        int cookievalue = 0;
        int asciivalue = n;
        
        for (long long m = k - 1; m >= 0; m--)
        {
          auto it = usedcookies.find(m);
          
          if (it == usedcookies.end())
          {
            break;
          }
          
          int currentpower = pow(2,m);
          
          if (currentpower <= asciivalue)
          {
            cookievalue += a[m];
          }
        }
        
        if (cookievalue == i)
        {
          for (long long m = k - 1; m >= 0; m--)
          {
            usedcookies.insert(m);
          }
        }
        else
        {
          validtastevalue = false;
        }
      }
    }
    
    if (validtastevalue)
    {
      returnvalue++;
    }
  }
  
  return returnvalue;
}

Compilation message (stderr)

biscuits.cpp:4:52: error: expected ',' or '...' before 'a'
    4 | long long count_tastiness(long long x, long long []a)
      |                                                    ^
biscuits.cpp: In function 'long long int count_tastiness(long long int, long long int*)':
biscuits.cpp:6:24: error: 'a' was not declared in this scope
    6 |   long long k = sizeof(a) / sizeof(a[0]);
      |                        ^