제출 #311648

#제출 시각아이디문제언어결과실행 시간메모리
311648andrew버섯 세기 (IOI20_mushrooms)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include <mushrooms.h>

#define fi first
#define se second
#define p_b push_back
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define pw(x) (1 << x);

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

ll count_mushrooms(int n){
    vector <int> m(n);
    iota(all(m), 0);
    int x = use_machine(m);
    if(x == 0)return n;
    m = {0, 1};
    int xt = use_machine(m);
    if(x == 1 && xt == 1)return 1;
    int uk = 2, ans = 2;
    int wh = 1;
    if(xt){
        int mx = 0;
        for(int i = 0; i <= 20; i++){
            if(pw(i) + 1 > n)break;
            m.resize(pw(i) + 1);
            iota(all(m), 0);
            if(use_machine(m) > 1)break;
            mx = i;
        }
        wh = pw(mx);
        for(int i = mx - 1; i >= 0; i--)if(wh + pw(i) < n){
            m.resize(pw(i) + wh + 1);
            iota(all(m), 0);
            if(use_machine(m) == 1)wh += pw(i);
        }
        wh++;
    }
    uk = wh + 1;
    while(uk + 1 < n){
        m = {0, uk, wh, uk + 1};
        int x = use_machine(m);
        ans += 2 - ((x + 1) / 2);
        uk += 2;
    }
    if(uk == n - 1){
        m = {0, uk};
        if(use_machine(m) == 0)ans++;
    }
    return ans;
}

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

mushrooms.cpp:17:4: error: ambiguating new declaration of 'll count_mushrooms(int)'
   17 | ll count_mushrooms(int n){
      |    ^~~~~~~~~~~~~~~
In file included from mushrooms.cpp:2:
mushrooms.h:3:5: note: old declaration 'int count_mushrooms(int)'
    3 | int count_mushrooms(int n);
      |     ^~~~~~~~~~~~~~~
mushrooms.cpp: In function 'll count_mushrooms(int)':
mushrooms.cpp:10:23: error: expected ')' before ';' token
   10 | #define pw(x) (1 << x);
      |                       ^
mushrooms.cpp:31:22: note: in expansion of macro 'pw'
   31 |             m.resize(pw(i) + 1);
      |                      ^~
mushrooms.cpp:31:21: note: to match this '('
   31 |             m.resize(pw(i) + 1);
      |                     ^
mushrooms.cpp:31:31: error: expected ';' before ')' token
   31 |             m.resize(pw(i) + 1);
      |                               ^
      |                               ;
mushrooms.cpp:31:28: warning: statement has no effect [-Wunused-value]
   31 |             m.resize(pw(i) + 1);
      |                            ^~~
mushrooms.cpp:37:47: warning: statement has no effect [-Wunused-value]
   37 |         for(int i = mx - 1; i >= 0; i--)if(wh + pw(i) < n){
      |                                               ^
mushrooms.cpp:37:55: error: expected primary-expression before '<' token
   37 |         for(int i = mx - 1; i >= 0; i--)if(wh + pw(i) < n){
      |                                                       ^
mushrooms.cpp:10:23: error: expected ')' before ';' token
   10 | #define pw(x) (1 << x);
      |                       ^
mushrooms.cpp:38:22: note: in expansion of macro 'pw'
   38 |             m.resize(pw(i) + wh + 1);
      |                      ^~
mushrooms.cpp:38:21: note: to match this '('
   38 |             m.resize(pw(i) + wh + 1);
      |                     ^
mushrooms.cpp:38:36: error: expected ';' before ')' token
   38 |             m.resize(pw(i) + wh + 1);
      |                                    ^
      |                                    ;
mushrooms.cpp:38:33: warning: statement has no effect [-Wunused-value]
   38 |             m.resize(pw(i) + wh + 1);
      |                            ~~~~~^~~