Submission #400181

#TimeUsernameProblemLanguageResultExecution timeMemory
400181VictorMeetings (JOI19_meetings)C++17
100 / 100
998 ms892 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = b - 1; i >= (a); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define umap unordered_map #define uset unordered_set typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long long ll; const int INF = 1000000007; struct edge { int u, v; }; vii EL; vi children[2001]; void solve(int u) { vi nodes = children[u]; children[u].clear(); int v = nodes[random() % sz(nodes)]; vi path; path.pb(u); rep(i, 0, sz(nodes)) { int cur = nodes[i]; if (cur == v) continue; int meet = Query(u, v, cur); if (meet == cur) { int lo = 1, hi = sz(path); while (lo < hi) { int mid = (hi + lo) >> 1; meet = Query(u, cur, path[mid]); if (meet == cur) hi = mid; else lo = mid + 1; } path.insert(path.begin() + lo, cur); } else children[meet].pb(cur); } path.pb(v); rep(i, 0, sz(path) - 1) EL.emplace_back(min(path[i], path[i + 1]), max(path[i], path[i + 1])); trav(node,path) if (sz(children[node])) solve(node); } void Solve(int N) { fill(children, children + 2001, vi()); rep(i, 1, N) children[0].pb(i); solve(0); sort(all(EL)); trav(edg, EL) Bridge(edg.first,edg.second); }

Compilation message (stderr)

meetings.cpp: In function 'void solve(int)':
meetings.cpp:7:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define rep(i, a, b) for (int i = a; i < (b); ++i)
      |                                        ^
meetings.cpp:42:5: note: in expansion of macro 'rep'
   42 |     rep(i, 0, sz(nodes)) {
      |     ^~~
meetings.cpp:7:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define rep(i, a, b) for (int i = a; i < (b); ++i)
      |                                        ^
meetings.cpp:69:5: note: in expansion of macro 'rep'
   69 |     rep(i, 0, sz(path) - 1) EL.emplace_back(min(path[i], path[i + 1]), max(path[i], path[i + 1]));
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...