Submission #1103696

#TimeUsernameProblemLanguageResultExecution timeMemory
1103696ortsacPolitical Development (BOI17_politicaldevelopment)C++17
77 / 100
3065 ms34696 KiB
#pragma GCC optmize("Ofast") #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() const int MAXN = 5e4 + 10; deque<int> adj[MAXN]; void merge(deque<int>& v1, deque<int>& v2, deque<int>& res) { int n = v1.size(), m = v2.size(); int p1 = 0, p2 = 0; while ((p1 < n) && (p2 < m)) { if (v1[p1] == v2[p2]) { res.push_back(v1[p1]); p1++; p2++; continue; } if (v1[p1] < v2[p2]) p1++; else p2++; } } int best(deque<int> pos) { int mx = 0; while (!pos.empty()) { auto u = pos.front(); pos.pop_front(); deque<int> nxt; merge(pos, adj[u], nxt); mx = max(mx, 1 + best(nxt)); } return mx; } int32_t main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { int x; cin >> x; while (x--) { int v; cin >> v; adj[i].push_back(v); } sort(adj[i].begin(), adj[i].end()); } int ans = 0; for (int i = 0; i < n; i++) { ans = max(ans, best(adj[i]) + 1); } cout << ans << "\n"; }

Compilation message (stderr)

politicaldevelopment.cpp:1: warning: ignoring '#pragma GCC optmize' [-Wunknown-pragmas]
    1 | #pragma GCC optmize("Ofast")
      |
#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...