Submission #424239

#TimeUsernameProblemLanguageResultExecution timeMemory
424239chirathnirodhaCounting Mushrooms (IOI20_mushrooms)C++17
Compilation error
0 ms0 KiB
//Coded by Chirath Nirodha #include "mushrooms.h" #include<bits/stdc++.h> #define F first #define S second #define PB push_back #define MP make_pair #define P push #define I insert typedef long long ll; typedef long double ld; typedef unsigned long long ull; using namespace std; const ll mod=1e9+7; int findbest(int n){ pair<int,int> x; x.F=100000; for(int i=0;i<1000;i++){ int temp=i+(2*(n-i-1)+i)/(i+1); if(temp<x.F){ x.F=temp; x.S=i; } } return i; } int count_mushrooms(int n) { vector<int> a,b; a.push_back(0); int cur=1; int bb=best(n); while(cur<n && cur<bb){ vector<int> m; m.PB(0);m.PB(cur); int x=use_machine(m); if(x==0)a.PB(cur); else b.PB(cur); cur++; } int ac=a.size(),bc=b.size(); if(a.size()>=b.size()){ while(cur<n){ vector<int> m; for(int i=0;i<a.size();i++){ m.PB(a[i]); if(cur==n || i==a.size()-1)break; m.PB(cur); cur++; } int x=use_machine(m); bc+=x/2; } return n-bc; } else{ while(cur<n){ vector<int> m; for(int i=0;i<b.size();i++){ m.PB(b[i]); if(cur==n || i==b.size()-1)break; m.PB(cur); cur++; } int x=use_machine(m); ac+=x/2; } return ac; } }

Compilation message (stderr)

mushrooms.cpp: In function 'int findbest(int)':
mushrooms.cpp:25:9: error: 'i' was not declared in this scope
   25 |  return i;
      |         ^
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:31:11: error: 'best' was not declared in this scope
   31 |    int bb=best(n);
      |           ^~~~
mushrooms.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |    for(int i=0;i<a.size();i++){
      |                ~^~~~~~~~~
mushrooms.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     if(cur==n || i==a.size()-1)break;
      |                  ~^~~~~~~~~~~~
mushrooms.cpp:58:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |    for(int i=0;i<b.size();i++){
      |                ~^~~~~~~~~
mushrooms.cpp:60:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     if(cur==n || i==b.size()-1)break;
      |                  ~^~~~~~~~~~~~