Submission #405340

#TimeUsernameProblemLanguageResultExecution timeMemory
405340Aryan_RainaPoklon (COCI17_poklon7)C++14
120 / 120
801 ms221680 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t #define ld long double #define ar array const int INF = 1e17; const int MOD = 1e9+7; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; vector<ar<int,2>> adj(N); for (auto &i : adj) { cin >> i[0] >> i[1]; if (i[0] > 0) --i[0]; if (i[1] > 0) --i[1]; } vector<string> remdi; function<int(int)> dfs = [&](int u)->int { if (u < 0) { remdi.push_back(""); for (int i = -u; i; i >>= 1) remdi.back() += '0' + (i & 1); reverse(remdi.back().begin(), remdi.back().end()); return (int) remdi.size() - 1; } int lc = dfs(adj[u][0]), rc = dfs(adj[u][1]), ans = lc; if (remdi[lc].size() == remdi[rc].size()) { for (int i = 0; i < remdi[lc].size(); i++) { if (remdi[lc][i] ^ remdi[rc][i]) { ans = (remdi[lc][i] - '0') ? lc : rc; break; } } } else { ans = (remdi[lc].size() > remdi[rc].size()) ? lc : rc; } remdi[ans] += '0'; return ans; }; cout << remdi[dfs(0)] << '\n'; }

Compilation message (stderr)

poklon.cpp: In lambda function:
poklon.cpp:34:28: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |          for (int i = 0; i < remdi[lc].size(); i++) {
      |                          ~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...