Submission #851104

#TimeUsernameProblemLanguageResultExecution timeMemory
8511041zaid1Meetings (JOI19_meetings)C++17
7 / 100
2 ms1112 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; mt19937 mt(time(0)); const int M = 2005; vector<int> sub[M]; int p[M]; void solve(int a) { vector<int> v; swap(v, sub[a]); int n = v.size(); if (!n) return; int b = v[0]; vector<int> nxt = {a, b}; for (int i:v) { if (i == a || i == b) continue; int x = Query(a, b, i); if (x == i) nxt.push_back(i); else sub[x].push_back(i), p[i] = x; } sort(nxt.begin(), nxt.end(), [a](int x, int y) { if (x == a) return true; if (y == a) return false; return Query(a, x, y) == x; }); for (int i = 1; i < nxt.size(); i++) p[nxt[i]] = nxt[i-1]; for (int i:nxt) solve(i); } void Solve(int n) { vector<int> v; int m = mt()%n; for (int i = 0; i < n; i++) if (i != m) v.push_back(i); sort(v.begin(), v.end(), [](int a, int b) {return mt()%2;}); sub[m] = v; p[m] = m; solve(m); for (int i = 0; i < n; i++) { if (i != p[i]) Bridge(min(p[i], i), max(p[i], i)); } }

Compilation message (stderr)

meetings.cpp: In function 'void solve(int)':
meetings.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 1; i < nxt.size(); i++) p[nxt[i]] = nxt[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...