Submission #1260161

#TimeUsernameProblemLanguageResultExecution timeMemory
1260161Seyyed_Mojtaba_MortazaviKoala Game (APIO17_koala)C++20
Compilation error
0 ms0 KiB
#include "koala.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 10; int minValue(int n, int w) { int b[n]; int r[n]; memset(b, 0, sizeof(b)); b[0] = 1; playRound(b, r); for (int i = 0; i < n; i++) { if (b[i] >= r[i]) return i; } } int maxValue(int n, int w) { int b[n]; int r[n]; vector <int> mx; for (int i = 0; i < n; i++) mx.push_back(i); while (mx.size() > 1) { memset(b, 0, sizeof(b)); int tmp = w / mx.size(); for (auto i : mx) b[i] = tmp; playRound(b, r); mx.clear(); for (int i = 0; i < n; i++) { if (r[i] > tmp) mx.push_back(i); } } return mx[0]; } int greaterValue(int n, int w) { int b[n]; int r[n]; memset(b, 0, sizeof(b)); int l = 1, r = 11; while (r - l > 1) { int mid = (l + r) >> 1; b[0] = b[1] = mid; playRound(b, r); if (r[0] > b[0] && r[1] > b[1]) l = mid; else if (r[0] <= b[0] && r[1] <= b[1]) r = mid; else return r[0] < r[1]; } } void allValues(int n, int w, int *p) { }

Compilation message (stderr)

koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:51:20: error: conflicting declaration 'int r'
   51 |         int l = 1, r = 11;
      |                    ^
koala.cpp:49:13: note: previous declaration as 'int r [n]'
   49 |         int r[n];
      |             ^
koala.cpp:52:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   52 |         while (r - l > 1)
      |                ~~~~~~^~~
koala.cpp:54:35: error: invalid operands of types 'int*' and 'int' to binary 'operator>>'
   54 |                 int mid = (l + r) >> 1;
      |                           ~~~~~~~ ^~ ~
      |                              |       |
      |                              int*    int
koala.cpp:60:27: error: incompatible types in assignment of 'int' to 'int [n]'
   60 |                         r = mid;
      |                         ~~^~~~~
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
   64 | }
      | ^