제출 #131126

#제출 시각아이디문제언어결과실행 시간메모리
131126IOrtroiiiMeetings (JOI19_meetings)C++14
100 / 100
1595 ms1068 KiB
#include <bits/stdc++.h> #include "meetings.h" using namespace std; mt19937 rng(10072002); void addEdge(int u, int v) { if (u > v) swap(u, v); Bridge(u, v); } void go(int from, vector<int> comp) { int id = rng() % (comp.size()); int to = comp[id]; swap(comp[id], comp.back()); comp.pop_back(); vector<int> path; vector<pair<int, int>> vals; for (int v : comp) { int u = Query(from, to, v); if (u == v) { path.push_back(v); } else { vals.emplace_back(u, v); } } if (path.empty()) { addEdge(from, to); } else { sort(path.begin(), path.end(), [&](int x, int y) { return Query(from, x, y) == x; }); addEdge(from, path[0]); for (int i = 0; i + 1 < path.size(); ++i) { addEdge(path[i], path[i + 1]); } addEdge(path.back(), to); } sort(vals.begin(), vals.end()); int l = 0; while (l < vals.size()) { vector<int> ncomp; int r = l; while (r < vals.size() && vals[l].first == vals[r].first) { ncomp.push_back(vals[r++].second); } go(vals[l].first, ncomp); l = r; } } void Solve(int n) { vector<int> comp(n - 1); iota(comp.begin(), comp.end(), 1); go(0, comp); }

컴파일 시 표준 에러 (stderr) 메시지

meetings.cpp: In function 'void go(int, std::vector<int>)':
meetings.cpp:34:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for (int i = 0; i + 1 < path.size(); ++i) {
                       ~~~~~~^~~~~~~~~~~~~
meetings.cpp:41:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while (l < vals.size()) {
           ~~^~~~~~~~~~~~~
meetings.cpp:44:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       while (r < vals.size() && vals[l].first == vals[r].first) {
              ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...