Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include "cave.h" #include
const int maxn = 5050; int S[maxn], D[maxn]; int switched[maxn]; void exploreCave(int N) { for(int i = 0; i < N; i++) { int comb = (tryCombination(S) != i); int L = 0, R = N - 1; while(L < R) { int mid = (L + R) / 2; for(int j = L; j <= mid; j++) { if(!switched[j]) { S[j] = 1 - S[j]; } } int comb2 = (tryCombination(S) != i); for(int j = L; j <= mid; j++) { if(!switched[j]) { S[j] = 1 - S[j]; } } if(comb == comb2) { L = mid + 1; } else { R = mid; } } D[L] = i; if(comb == 0) { S[L] = 1 - S[L]; } switched[L] = 1; } answer(S, D); }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)