| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 561928 | timreizin | Meetings (JOI19_meetings) | C++17 | 621 ms | 816 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include "meetings.h"
#include <random>
#include <vector>
#include <set>
#include <numeric>
#include <algorithm>
#include <map>
using namespace std;
vector<vector<int>> adj;
mt19937 gen(53497);
void find(vector<int> &vertices)
{
if (vertices.size() == 1) return;
if (vertices.size() == 2)
{
adj[vertices.front()].push_back(vertices.back());
adj[vertices.back()].push_back(vertices.front());
return;
}
vector<int> path;
map<int, vector<int>> comps;
int x = uniform_int_distribution<>(0, (int)vertices.size() - 1)(gen);
int y = x;
while (y == x) y = uniform_int_distribution<>(0, (int)vertices.size() - 1)(gen);
x = vertices[x];
y = vertices[y];
path.push_back(x);
for (int i = 0; i < vertices.size(); ++i)
{
if (x == vertices[i] || y == vertices[i]) continue;
int r = Query(x, y, vertices[i]);
if (r != vertices[i]) comps[r].push_back(vertices[i]);
else path.push_back(r);
}
for (auto &[pivot, vertices] : comps)
{
vertices.push_back(pivot);
find(vertices);
}
sort(path.begin() + 1, path.end(), [&x](int a, int b) { return Query(x, a, b) == a; });
path.push_back(y);
for (int i = 0; i + 1 < path.size(); ++i)
{
adj[path[i]].push_back(path[i + 1]);
adj[path[i + 1]].push_back(path[i]);
}
}
void Solve(int n)
{
adj.resize(n);
set<int> path;
vector<int> vertices(n);
iota(vertices.begin(), vertices.end(), 0);
find(vertices);
for (int i = 0; i < n; ++i) for (int u : adj[i]) if (i < u) Bridge(i, u);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
