Submission #400179

#TimeUsernameProblemLanguageResultExecution timeMemory
400179VictorMeetings (JOI19_meetings)C++17
100 / 100
1002 ms960 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])); rep(i, 0, sz(path)) if (sz(children[path[i]])) solve(path[i]); } 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]));
      |     ^~~
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:71:5: note: in expansion of macro 'rep'
   71 |     rep(i, 0, sz(path)) if (sz(children[path[i]])) solve(path[i]);
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...