제출 #547487

#제출 시각아이디문제언어결과실행 시간메모리
547487beaconmc동굴 (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "cave.h"

typedef long long ll;
using namespace std;
using namespace __gnu_pbds;

#define FOR(i, x, y) for(int i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll int


vector<vector<ll>> found;

ll test(int n){
    vector<ll> ans;
    FOR(i,0,n) ans.push_back(0);
    for (auto&i : found){
        ans[i[1]] = i[2];
    }
    ll result = tryCombination(ans);
    if (result>=n || result==-1){
        return 0;
    }else{
        return 1;
    }

}

ll test2(int n, int k, int s){
    vector<ll> ans;
    FOR(i,0,n) ans.push_back(0);
    FOR(i,0,k) ans[i] = s;
    for (auto&i : found){
        ans[i[1]] = i[2];
    }
    ll result = tryCombination(ans);
    if (result>=n || result==-1){
        return 1;
    }else{
        return 0;
    }

}

void exploreCave(int N){
    FOR(i,0,N){
        ll switchd = test(i);
        ll lo = 1;
        ll hi = N+1;
        while (lo < hi) {
            int mid = lo + (hi - lo) / 2;
            if (test2(N, mid, switchd)) {
                hi = mid;
            } else {
                lo = mid + 1;
            }
        };
        found.push_back({i, lo, switchd});
    }
    vector<ll> S(N);
    vector<ll> D(N);
    for(auto&i : found){
        S[i[0]] = i[2];
        D[i[0]] = i[1];

    }

    answer(S,D);

}

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

cave.cpp: In function 'int test(int)':
cave.cpp:25:32: error: cannot convert 'std::vector<int>' to 'int*'
   25 |     ll result = tryCombination(ans);
      |                                ^~~
      |                                |
      |                                std::vector<int>
In file included from cave.cpp:4:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp: In function 'int test2(int, int, int)':
cave.cpp:41:32: error: cannot convert 'std::vector<int>' to 'int*'
   41 |     ll result = tryCombination(ans);
      |                                ^~~
      |                                |
      |                                std::vector<int>
In file included from cave.cpp:4:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:73:12: error: cannot convert 'std::vector<int>' to 'int*'
   73 |     answer(S,D);
      |            ^
      |            |
      |            std::vector<int>
In file included from cave.cpp:4:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~