Submission #467515

#TimeUsernameProblemLanguageResultExecution timeMemory
467515Valaki2Cave (IOI13_cave)C++14
0 / 100
65 ms420 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave(int N) { int n = N; int correctPosition[n]; int connectedDoor[n]; int tryCombinationArray[n]; for(int i = 0; i < n; ++i) { correctPosition[i] = -1; connectedDoor[i] = -1; tryCombinationArray[i] = 0; } for(int i = 0; i < n; ++i) { for(int j = 0; j < n; ++j) { if(correctPosition[j] == -1) { tryCombinationArray[j] = 0; } else { tryCombinationArray[j] = correctPosition[j]; } } int pos = tryCombination(tryCombinationArray); if(pos == i) pos = 1; else pos = 0; int l = 0, r = n; int swappedTo = 0; while(l < r - 1) { int ce = (l + r) / 2; for(int j = l; j < ce; ++j) { if(correctPosition[j] == -1) { tryCombinationArray[j] = 1 - tryCombinationArray[j]; swappedTo = tryCombinationArray[j]; } else { tryCombinationArray[j] = correctPosition[j]; } } int result = tryCombination(tryCombinationArray); if(((pos == swappedTo) && (result != i)) || ((pos != swappedTo) && (result == i))) { r = ce; } else { l = ce; } } connectedDoor[l] = i; correctPosition[l] = pos; /*cout << i << ":\n"; for(int j = 0; j < n; ++j) cout << connectedDoor[j] << " "; cout << "\n"; for(int j = 0; j < n; ++j) cout << correctPosition[j] << " "; cout << "\n";*/ } answer(correctPosition, connectedDoor); }
#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...