Submission #909623

#TimeUsernameProblemLanguageResultExecution timeMemory
909623MilosMilutinovic라멘 (JOI14_ramen)C++14
100 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "ramen.h" using namespace std; void Ramen(int n) { if (n == 1) { Answer(0, 0); return; } auto Ask = [&](int i, int j) { return Compare(i, j); }; vector<int> s; for (int i = 0; i < n - n % 2; i += 2) { s.push_back(Ask(i, i + 1)); } int mn = 0, mx = 1; if (s[0] == -1) { swap(mn, mx); } for (int i = 1; i < (int) s.size(); i++) { int x = 2 * i, y = 2 * i + 1; if (s[i] == -1) { swap(x, y); } if (Ask(x, mn) == 1) { mn = x; } if (Ask(mx, y) == 1) { mx = y; } } if (n % 2 == 1) { if (Ask(n - 1, mn) == 1) { mn = n - 1; } if (Ask(mx, n - 1) == 1) { mx = n - 1; } } Answer(mx, mn); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...