Submission #571939

#TimeUsernameProblemLanguageResultExecution timeMemory
571939SlavicG동굴 (IOI13_cave)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

/*
int tryCombination(vector<int> s) {
    for(auto x: s) cout << x << " ";
    cout << "\n";
    int f; cin >> f;
    return f;
}
void answer(vector<int> s, vector<int> d) {
    for(auto x: s) cout << x << " ";
    cout << "\n";
    for(auto x: d) cout << x << " ";
        cout << "\n";
}

*/

void exploreCave(int n) {
    vector<int> d(n, -1);
    vector<int> s(n, -1);

    int lst = -1;

    for(int i = 0; i < n; ++i) {
        vector<int> tmp = s;
        forn(j, n) if(s[j] == -1) tmp[j] = 0;
        int x = tryCombination(tmp);
        int need = 0;
        if(x == -1) x = n;
        if(x <= i) {
            need = 1;
            forn(j, n) if(s[j] == -1) tmp[j] = 1;
        } 
        d[i] = need;
        int l = 0, r = n - 1, pos = -1;
        while(l <= r) {
            int mid = l + r >> 1;
            for(int j = mid; j < n; ++j) {
                if(s[j] == -1) {
                    tmp[j] = !need;
                }
            }
            x = tryCombination(tmp);
            if(x <= i) {
                r = mid - 1;
            } else {
                pos = mid;
                l = mid + 1;
            }
        }
        s[pos] = i;
    }
    answer(s, d);
}

/*
void solve() {
    int n; cin >> n;
    exploreCave(n);
}
     
int32_t main() {
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}
*/

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:38:17: error: 'tryCombination' was not declared in this scope
   38 |         int x = tryCombination(tmp);
      |                 ^~~~~~~~~~~~~~
cave.cpp:48:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |             int mid = l + r >> 1;
      |                       ~~^~~
cave.cpp:64:5: error: 'answer' was not declared in this scope
   64 |     answer(s, d);
      |     ^~~~~~
cave.cpp:33:9: warning: unused variable 'lst' [-Wunused-variable]
   33 |     int lst = -1;
      |         ^~~