제출 #589333

#제출 시각아이디문제언어결과실행 시간메모리
589333LIF버섯 세기 (IOI20_mushrooms)C++14
80.71 / 100
8 ms344 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; int count_mushrooms(int n) { std::vector <int> m; vector<int> a; vector<int> b; int aans = 1; int bans = 0; a.push_back(0); bool check[200005]; int pointer = 1; while(pointer<n) { m.clear(); if(a.size() >= b.size()) { if(a.size()==1) { m.push_back(0); m.push_back(pointer); if(use_machine(m) == 1) //that means 1 is b { bans++; b.push_back(pointer); } else //that means pointer is a { aans++; a.push_back(pointer); } check[pointer] = true; pointer++; } else { int fir = pointer; for(int i=0;i<a.size()*2;i++) { if(i==0) { m.push_back(fir); check[fir] = true; pointer++; } else { if(i%2==1) { m.push_back(a[i/2]); } else { if(pointer>=n)break; //that means we can confirm the count of m's element is even. m.push_back(pointer); check[pointer] = true; pointer++; } } } int kk = use_machine(m); if(kk%2 == 1)//that means the first is b; { b.push_back(fir); bans++; kk+=1; //that means we can ignore the first element. } //that means the first is A else { a.push_back(fir); } kk/=2; //it is the count of kk; aans += (m.size() - (m.size()/2) - kk); } } else { int fir = pointer; for(int i=0;i<b.size()*2;i++) { if(i==0) { m.push_back(fir); check[fir] = true; pointer++; } else { if(i%2==1) { m.push_back(b[i/2]); } else { if(pointer >=n)break; m.push_back(pointer); check[pointer] = true; pointer++; } } } int kk = use_machine(m); if(kk%2==1) //the first is A { a.push_back(fir); kk+=1; } else { b.push_back(fir); bans++; } kk/=2; aans += kk; } } return aans; }

컴파일 시 표준 에러 (stderr) 메시지

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i=0;i<a.size()*2;i++)
      |                 ~^~~~~~~~~~~
mushrooms.cpp:83:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |    for(int i=0;i<b.size()*2;i++)
      |                ~^~~~~~~~~~~
mushrooms.cpp:13:7: warning: variable 'check' set but not used [-Wunused-but-set-variable]
   13 |  bool check[200005];
      |       ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...