Submission #412036

#TimeUsernameProblemLanguageResultExecution timeMemory
412036mosiashvililukaCounting Mushrooms (IOI20_mushrooms)C++17
75.59 / 100
11 ms456 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; int a,b,c,d,e,i,j,ii,jj,zx,xc,A,B,T=30,cnt; int SUB; string QWE; vector <int> vA,vB,vv; /*int use_machine(vector <int> q){ int we=0; for(int qw=1; qw<q.size(); qw++){ if(QWE[q[qw]]!=QWE[q[qw-1]]){ we++; } } return we; }*/ int count_mushrooms(int n) { a=n; vA.push_back(0); A++; cnt=1; for(i=1; i<a; i++){ if(vA.size()>=T||vB.size()>=T) break; vv.clear();vv.push_back(0);vv.push_back(i); c=use_machine(vv); if(c==0){ vA.push_back(i); A++; }else{ vB.push_back(i); B++; } cnt++; } if(vA.size()>=T){ SUB=0; }else{ SUB=1; swap(vA,vB); swap(A,B); } while(cnt<a){ vv.clear(); e=cnt;d=0; for(i=e; i<e+vA.size(); i++){ if(i>=a) break; vv.push_back(vA[i-e]); vv.push_back(i); d++; cnt++; } c=use_machine(vv); zx=c/2+c%2; A+=(d-zx); if(c%2==0){ vA.push_back(cnt-1); } } if(SUB==1) A=n-A; return A; } /*int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); //cin>>a; cin>>QWE; zx=0; for(i=0; i<QWE.size(); i++){ if(QWE[i]=='A'){ zx++; } } cout<<"A: "<<zx<<endl; cout<<count_mushrooms(QWE.size()); return 0; }*/

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:23:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |   if(vA.size()>=T||vB.size()>=T) break;
      |      ~~~~~~~~~^~~
mushrooms.cpp:23:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |   if(vA.size()>=T||vB.size()>=T) break;
      |                    ~~~~~~~~~^~~
mushrooms.cpp:35:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |  if(vA.size()>=T){
      |     ~~~~~~~~~^~~
mushrooms.cpp:45:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(i=e; i<e+vA.size(); i++){
      |            ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...