Submission #633283

#TimeUsernameProblemLanguageResultExecution timeMemory
633283ghostwriterCave (IOI13_cave)C++14
0 / 100
517 ms432 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#include "grader.c"
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
    Tran The Bao
    CTL - Da Lat
    Practising for VOI23 gold medal
*/
const int MAXN = 5000;
int b[MAXN], s[MAXN], a[MAXN];
void exploreCave(int N) {
    FOR(i, 0, N - 1) b[i] = 1;
    int correctd = tryCombination(b);
    int correctp = -1;
    FOR(i, 0, N - 1) {
        FOR(j, 0, N - 1) b[j] = 1;
        b[i] = 0;
        int tmp = tryCombination(b);
        if (tmp == -1) correctp = i;
    }
    FOR(i, 0, N - 1) {
        s[i] = 1;
        a[i] = -1;
    }
    a[correctp] = correctd;
    s[correctp] = 0;
    FOR(i, 0, N - 1) {
        if (i == correctd) continue;
        int l = 0, r = N - 1, ans = -1;
        WHILE(l <= r) {
            int mid = l + (r - l) / 2;
            FOR(j, 0, N - 1)
                if (a[j] != -1) b[j] = s[j];
                else b[j] = !s[j];
            FOR(j, 0, mid)
                if (a[j] == -1)
                    b[j] = 1;
            int tmp = tryCombination(b);
            if (tmp == -1 || tmp > i) {
                ans = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        a[ans] = i;
    }
    answer(s, a);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
cave.cpp:41:5: note: in expansion of macro 'FOR'
   41 |     FOR(i, 0, N - 1) b[i] = 1;
      |     ^~~
cave.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
cave.cpp:44:5: note: in expansion of macro 'FOR'
   44 |     FOR(i, 0, N - 1) {
      |     ^~~
cave.cpp:26:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
cave.cpp:45:9: note: in expansion of macro 'FOR'
   45 |         FOR(j, 0, N - 1) b[j] = 1;
      |         ^~~
cave.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
cave.cpp:50:5: note: in expansion of macro 'FOR'
   50 |     FOR(i, 0, N - 1) {
      |     ^~~
cave.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
cave.cpp:56:5: note: in expansion of macro 'FOR'
   56 |     FOR(i, 0, N - 1) {
      |     ^~~
cave.cpp:26:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
cave.cpp:61:13: note: in expansion of macro 'FOR'
   61 |             FOR(j, 0, N - 1)
      |             ^~~
cave.cpp:26:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
cave.cpp:64:13: note: in expansion of macro 'FOR'
   64 |             FOR(j, 0, mid)
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...