제출 #413828

#제출 시각아이디문제언어결과실행 시간메모리
413828ivan24버섯 세기 (IOI20_mushrooms)C++14
컴파일 에러
0 ms0 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; using ll = int; typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll,ll> ii; typedef vector<ii> vii; typedef vector<vii> vvii; #define F first #define S second int main() { check_input(1 == scanf("%d", &n), "Could not read n."); check_input(min_n <= n, "n must not be less than %d, but it is %d.", min_n, n); check_input(n <= max_n, "n must not be greater than %d, but it is %d.", max_n, n); species.resize(n); for (int i = 0; i < n; i++) { check_input(1 == scanf("%d", &species[i]), "Could not read species element [%d].", i); check_input(species[i]==species_A || species[i] == species_B, "Species elements must be %d or %d, but species element [%d] is %d.", species_A, species_B, i, species[i]); } check_input(species[0] == species_A, "Species element [%d] must be %d.", 0, species_A); // Postponed closing standard input in order to allow interactive usage of the grader. qc = 0; qs = 0; int answer = count_mushrooms(n); printf("%d\n%d\n", answer, qc); fclose(stdout); fclose(stdin); return 0; } class Solver{ private: ll n; vvi known; void typeZeroQuery (ll x){ ll res = use_machine(vi{0,x}); known[res].push_back(x); } void typeOneQuery(ll x1, ll x2){ ll curType = 0; if (2 > known[0].size()) curType = 1; vi v = {known[curType][0],x1,known[curType][1],x2}; ll res = use_machine(v); if (res & 2){ known[1-curType].push_back(x1); }else{ known[curType].push_back(x1); } if (res & 1){ known[1-curType].push_back(x2); }else{ known[curType].push_back(x2); } } public: Solver(ll n): n(n){ } ll solve(){ known.assign(2,vi()); known[0].push_back(0); for (ll i = 1; 3 > i; i++){ typeZeroQuery(i); } for (ll i = 3; n > i+1; i+=2){ typeOneQuery(i,i+1); } if (n%2 == 0) typeZeroQuery(n-1); return known[0].size(); } }; int count_mushrooms(int n) { Solver mySolver(n); return mySolver.solve(); }

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

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:16:32: error: 'n' was not declared in this scope; did you mean 'yn'?
   16 |  check_input(1 == scanf("%d", &n), "Could not read n.");
      |                                ^
      |                                yn
mushrooms.cpp:16:2: error: 'check_input' was not declared in this scope
   16 |  check_input(1 == scanf("%d", &n), "Could not read n.");
      |  ^~~~~~~~~~~
mushrooms.cpp:17:14: error: 'min_n' was not declared in this scope
   17 |  check_input(min_n <= n, "n must not be less than %d, but it is %d.", min_n, n);
      |              ^~~~~
mushrooms.cpp:18:19: error: 'max_n' was not declared in this scope
   18 |  check_input(n <= max_n, "n must not be greater than %d, but it is %d.", max_n, n);
      |                   ^~~~~
mushrooms.cpp:19:2: error: 'species' was not declared in this scope
   19 |  species.resize(n);
      |  ^~~~~~~
mushrooms.cpp:22:27: error: 'species_A' was not declared in this scope
   22 |   check_input(species[i]==species_A || species[i] == species_B,
      |                           ^~~~~~~~~
mushrooms.cpp:22:54: error: 'species_B' was not declared in this scope
   22 |   check_input(species[i]==species_A || species[i] == species_B,
      |                                                      ^~~~~~~~~
mushrooms.cpp:25:28: error: 'species_A' was not declared in this scope
   25 |  check_input(species[0] == species_A, "Species element [%d] must be %d.", 0, species_A);
      |                            ^~~~~~~~~
mushrooms.cpp:28:2: error: 'qc' was not declared in this scope
   28 |  qc = 0;
      |  ^~
mushrooms.cpp:29:2: error: 'qs' was not declared in this scope
   29 |  qs = 0;
      |  ^~