Submission #1057368

#TimeUsernameProblemLanguageResultExecution timeMemory
1057368c2zi6Counting Mushrooms (IOI20_mushrooms)C++14
53.94 / 100
6 ms600 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "mushrooms.h" int count_mushrooms(int n) { int x = 140; VI mek, zro; zro.pb(0); int ans = 1; int last = 1; replr(i, 1, n-1) { if (use_machine({0, i})) { mek.pb(i); } else { ans++; zro.pb(i); } last = i+1; if (mek.size() == x || zro.size() == x) break; } while (last < n) { VI qr; for (int x : (mek.size() > zro.size() ? mek : zro)) { qr.pb(x); qr.pb(last++); if (last >= n) break; } int ret = use_machine(qr); int urish = (ret+1)/2; /*cout << "QUERIED ON ";*/ /*for (int x : qr) cout << x << " "; cout << endl;*/ /*cout << "DIFFERENT SPECIES " << urish << endl;*/ /*cout << "ADDED " << qr.size()/2-urish << endl;*/ if (mek.size() > zro.size()) ans += urish; else ans += qr.size()/2 - urish; } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:48:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |         if (mek.size() == x || zro.size() == x) break;
      |             ~~~~~~~~~~~^~~~
mushrooms.cpp:48:43: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |         if (mek.size() == x || zro.size() == x) break;
      |                                ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...