Submission #613621

#TimeUsernameProblemLanguageResultExecution timeMemory
613621Jarif_Rahman버섯 세기 (IOI20_mushrooms)C++17
0 / 100
1 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int count_mushrooms(int n){ vector<int> A, B; A.pb(0); int sq = sqrt(n); sq = max(2, sq); sq = 2; int ls = 1; for(int i = 1; i < n; i++){ if(use_machine({0, i})) B.pb(i); else A.pb(i); if(max(A.size(), B.size()) >= sq){ ls = i; break; } } sq--; int ans = A.size(); if(A.size() == sq+1){ for(int i = ls+1; i < n; i+=sq){ vector<int> Q; for(int j = 0; j < sq; j++){ Q.pb(A[j]); if(i+j < min(n, i+sq)) Q.pb(i+j); } Q.pb(A.back()); ans+=min(n, i+sq)-i+1-use_machine(Q)/2; } } else{ for(int i = ls+1; i < n; i+=sq){ vector<int> Q; for(int j = 0; j < sq; j++){ Q.pb(B[j]); if(i+j < min(n, i+sq)) Q.pb(i+j); } Q.pb(B.back()); ans+=use_machine(Q)/2; } } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:23:36: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
   23 |         if(max(A.size(), B.size()) >= sq){
      |            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
mushrooms.cpp:33:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |     if(A.size() == sq+1){
      |        ~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...