제출 #1298188

#제출 시각아이디문제언어결과실행 시간메모리
1298188orgiloogiiCounting Mushrooms (IOI20_mushrooms)C++20
컴파일 에러
0 ms0 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #define int long long using namespace std; //int count_mushrooms(int n) { // std::vector<int> m; // for (int i = 0; i < n; i++) // m.push_back(i); // int c1 = use_machine(m); // m = {0, 1}; // int c2 = use_machine(m); // return c1+c2; //} int count_mushrooms(int n) { // vector <int> m; vector <int> as, bs; as.push_back(0); int i = 1; while (i < n && as.size() < 100 && bs.size() < 100) { if (use_machine({0, i}) == 1) { bs.push_back(i); } else { as.push_back(i); } i++; } if (i == n) { return as.size(); } ans = as.size(); if (bs.size() == 100) { while (i < n) { int j = i + 1; vector <int> m; while (j < n && j <= i + 100) { m.push_back(bs[j - i - 1]); m.push_back(j); j++; } int c = use_machine(m); if (c % 2 == 1) { ans += 1; } ans += c / 2; i = j; } return ans; } while (i < n) { int j = i + 1; int cnt = 0; vector <int> m; while (j < n && j <= i + 100) { m.push_back(as[j - i - 1]); m.push_back(j); j++; cnt++; } int c = use_machine(m); ans += cnt - (c / 2); } return ans; }

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

mushrooms.cpp: In function 'long long int count_mushrooms(long long int)':
mushrooms.cpp:21:37: warning: narrowing conversion of 'i' from 'long long int' to 'int' [-Wnarrowing]
   21 |                 if (use_machine({0, i}) == 1) {
      |                                     ^
mushrooms.cpp:21:37: warning: narrowing conversion of 'i' from 'long long int' to 'int' [-Wnarrowing]
mushrooms.cpp:32:9: error: 'ans' was not declared in this scope; did you mean 'as'?
   32 |         ans = as.size();
      |         ^~~
      |         as
mushrooms.cpp:42:45: error: could not convert 'm' from 'vector<long long int>' to 'vector<int>'
   42 |                         int c = use_machine(m);
      |                                             ^
      |                                             |
      |                                             vector<long long int>
mushrooms.cpp:61:37: error: could not convert 'm' from 'vector<long long int>' to 'vector<int>'
   61 |                 int c = use_machine(m);
      |                                     ^
      |                                     |
      |                                     vector<long long int>