Submission #546226

#TimeUsernameProblemLanguageResultExecution timeMemory
546226LunaMemeCave (IOI13_cave)C++14
0 / 100
2089 ms52132 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef vector<pair<int, int>> vii; typedef vector<int> vi; typedef long long ll; #define PB push_back #define MP make_pair #define FOR(i, x, y) for (int i = x; i < y ; i ++) /*int N; vi S, D, C; void answer(vi A, vi B) { for(int i = 0; i < N; i ++) cout << A[i] << ' '; cout << '\n'; for(int i = 0; i < N; i ++) cout << B[i] << ' '; } int tryCombination(vi A) { for(int door = 0; door < N;door ++) { if(A[C[door]] != S[C[door]]) return door; } return -1; }*/ int opp(int d){ if (d == 1)return 0; return 1; } void exploreCave(int N) { int arr[N]; memset(arr, -1, sizeof arr); int ans[N]; FOR(i, 0, N){ //door int temp[N]; FOR(k, 0, N){ if (arr[k] == -1)temp[k] = 0; else temp[k] = arr[k]; } int j = tryCombination(temp); int d = 0; //d is colour of i th switch if (j <= i && j > -1){ d = 1; } //binary search FOR(k, 0, N){ if (arr[k] == -1)temp[k] = d; else temp[k] = arr[k]; } int l = 0, r = N - 1; while(l < r){ int m = (l + r) / 2; FOR(k, l, m + 1){ if (arr[k] == -1) temp[k] = opp(d); else temp[k] = arr[k]; } FOR(k, 0, N){ cout << temp[k] << ' '; } cout << '\n'; j = tryCombination(temp); if (j > i || j == -1) //passes { l = m + 1; } else{ r = m; } FOR(k, 0, N){ if (arr[k] == -1)temp[k] = d; else temp[k] = arr[k]; } } assert(l == r); //cout << "Door " << i << " connects to switch " << l << '\n'; //assert(arr[l] == -1); arr[l] = d; ans[l] = i; } answer(arr, ans); } /*int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N; S.assign(N,0); D.assign(N,0); C.assign(N,0); for(int i = 0; i < N; i ++) cin >> S[i]; for(int i = 0; i < N; i ++) cin >> D[i]; for(int i = 0; i < N; i ++) C[D[i]] = i; exploreCave(N); } */
#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...