Submission #839920

#TimeUsernameProblemLanguageResultExecution timeMemory
839920Alihan_8Cave (IOI13_cave)C++17
0 / 100
2 ms596 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define pb push_back using i64 = long long; template <typename _F, typename _S> bool chmax(_F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag = true; } return flag; } template <typename _F, typename _S> bool chmin(_F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag = true; } return flag; } void exploreCave(int n) { int ans[n], p[n], used[n]; memset(ans, 0, sizeof(ans)); memset(used, false, sizeof(used)); for ( int i = 0; i < n; i++ ){ vector <int> a; for ( int j = 0; j < n; j++ ){ if ( !used[j] == -1 ){ a.pb(j); } } int m = (int)a.size(), l = 0, r = m - 1; bool flag = false; while ( l <= r ){ int md = (l + r) >> 1; int a_l = tryCombination(ans); for ( int i = l; i <= md; i++ ) ans[a[i]] = 1; int a_r = tryCombination(ans); for ( int i = l; i <= md; i++ ) ans[a[i]] = 0; if ( a_l == a_r ) l = md + 1; else{ if ( l == md ){ flag = a_l < a_r; break; } else r = md; } } l = a[l]; ans[l] = flag; p[l] = i; used[l] = true; } answer(ans, p); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:39:18: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
   39 |    if ( !used[j] == -1 ){
      |                  ^~
cave.cpp:39:9: note: add parentheses around left hand side expression to silence this warning
   39 |    if ( !used[j] == -1 ){
      |         ^~~~~~~~
      |         (       )
cave.cpp:39:18: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare]
   39 |    if ( !used[j] == -1 ){
      |         ~~~~~~~~~^~~~~
#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...