Submission #114025

# Submission time Handle Problem Language Result Execution time Memory
114025 2019-05-29T15:38:12 Z dolphingarlic Carnival (CEOI14_carnival) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define FOR(i, x, y) for(int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int a[151];

void solve(int lower, int upper, int l, int r) {
    if (l == r) a[l] = lower;
    else {
        int mid = (l + r) / 2;
        cout << mid - l + 1 << ' ';
        FOR(i, l, mid + 1) cout << i << ' ';
        cout << endl;
        int k;
        cin >> k;
        solve(lower, lower + k - 1, l, mid);
        cout << r - mid << ' ';
        FOR(i, mid + 1, r + 1) cout << i << ' ';
        cout << endl;
        int k;
        cin >> k;
        solve(upper - k + 1, upper, mid + 1, r);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    cout << n << ' ';
    FOR(i, 1, n + 1) cout << i << ' ';
    cout << endl;
    int k;
    cin >> k;
    solve(1, k, 1, n);
    cout << "0 ";
    FOR(i, 1, n + 1) cout << a[i] << ' ';
    cout << endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'void solve(int, int, int, int)':
carnival.cpp:22:13: error: redeclaration of 'int k'
         int k;
             ^
carnival.cpp:16:13: note: 'int k' previously declared here
         int k;
             ^