제출 #424286

#제출 시각아이디문제언어결과실행 시간메모리
424286Supersonic버섯 세기 (IOI20_mushrooms)C++14
25 / 100
32 ms432 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int o(int n){ int b=-1,m=1e9; for(int i=1;i<n;i++){ if(2*i+(n-(2*i))/i<m){m=2*i+(n-(2*i))/i;b=i;} } return max(2,b); } int count_mushrooms(int n) { vector<int> a={0}; vector<int> b;int c=1; int p=o(n);cerr<<p<<endl; while(a.size()<2&&b.size()<2&&c<n){ int k=use_machine({0,c}); if(k==1)b.push_back(c);else a.push_back(c); c++; } if(c==n)return a.size(); if(a.size()==2){ while(a.size()<p&&b.size()<p&&c<n-1){ int k=use_machine({a[0],c,a[1],c+1}); if(k==3){b.push_back(c);b.push_back(c+1);} if(k==2){b.push_back(c);a.push_back(c+1);} if(k==1){a.push_back(c);b.push_back(c+1);} if(k==0){a.push_back(c);a.push_back(c+1);} c+=2; } if(c==n-1){ int k=use_machine({a[0],c}); if(k==1){b.push_back(c);} else a.push_back(c); c++; } } else { while(a.size()<p&&b.size()<p&&c<n-1){ int k=use_machine({b[0],c,b[1],c+1}); if(k==3){a.push_back(c);a.push_back(c+1);} if(k==2){a.push_back(c);b.push_back(c+1);} if(k==1){b.push_back(c);a.push_back(c+1);} if(k==0){b.push_back(c);b.push_back(c+1);} c+=2; } if(c==n-1){ int k=use_machine({b[0],c}); if(k==1){a.push_back(c);} else b.push_back(c); c++; } } int ca=a.size(),cb=b.size(); if(c==n)return ca; //for(auto i:a)cerr<<i<<' ';cerr<<endl; if(a.size()==p){ //cerr<<a[0]<<':'<<a[1]<<endl; while(c<n){ vector<int> r; for(auto i:a){r.push_back(i);r.push_back(c);c++;if(c==n)break;} //for(auto i:r)cerr<<i<<' ';cerr<<endl; int k=use_machine(r);if(k%2==0)a.push_back(r.back()); cb+=(k+1)/2; } return n-cb; } else { while(c<n){ vector<int> r; for(auto i:b){r.push_back(i);r.push_back(c);c++;if(c==n)break;} //for(auto i:r)cerr<<i<<' ';cerr<<endl; int k=use_machine(r);if(k%2==0)b.push_back(r.back()); ca+=(k+1)/2; } return ca; } exit(1); }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:22:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |   while(a.size()<p&&b.size()<p&&c<n-1){
      |         ~~~~~~~~^~
mushrooms.cpp:22:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |   while(a.size()<p&&b.size()<p&&c<n-1){
      |                     ~~~~~~~~^~
mushrooms.cpp:38:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |   while(a.size()<p&&b.size()<p&&c<n-1){
      |         ~~~~~~~~^~
mushrooms.cpp:38:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |   while(a.size()<p&&b.size()<p&&c<n-1){
      |                     ~~~~~~~~^~
mushrooms.cpp:56:13: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |  if(a.size()==p){
      |     ~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...