Submission #821844

# Submission time Handle Problem Language Result Execution time Memory
821844 2023-08-11T19:07:10 Z farhan132 Meetings (JOI19_meetings) C++17
100 / 100
558 ms 856 KB
#include "meetings.h"
#include <bits/stdc++.h>

using namespace std;
 
typedef int ll;
typedef double dd;
typedef pair<ll , ll> ii;
typedef tuple < ll,  ll, ll > tp;
 
#define ff first
#define ss second
#define pb push_back
#define in insert

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const ll N = 2005;
vector < ll > v[N];
ll col[N];

void dfs(ll s){
  if(col[s]) return;
  col[s] = 1;
  for(auto u : v[s]) dfs(u);
}
vector < ii > e;

void solve(ll root, vector < ll > a){
  if(a.size() == 0) return;
  
  for(auto u : a){
   v[u].clear();
  }
  v[root].clear();
  shuffle(a.begin(), a.end(), rng);
  vector < ll > nodes = {a[0]};
  for(ll i = 1; i < a.size(); i++){
    ll z = Query(root, a[0], a[i]);
    if(z != a[i]) v[z].pb(a[i]);
    if(z != root) nodes.pb(z);
  }

  sort(nodes.begin(), nodes.end());
  nodes.erase(unique(nodes.begin(), nodes.end()), nodes.end());

  sort(nodes.begin(), nodes.end(), [&](ll i, ll j){

    return (Query(root, i, j) == i);
  });
  e.pb({root, nodes[0]});
  for(ll i = 1; i < nodes.size(); i++){
    e.pb({nodes[i - 1], nodes[i]});
  }
  nodes.pb(root);
  for(auto u : nodes){
    solve(u, v[u]);
  }

  return;
}

void Solve(int n) {
  vector < ll > a;
  for(ll i = 1; i < n; i++) a.pb(i);
  solve(0, a);

  for(auto [x, y] : e){
    Bridge(min(x, y), max(x, y));
  }

  return;
}

Compilation message

meetings.cpp: In function 'void solve(ll, std::vector<int>)':
meetings.cpp:38:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for(ll i = 1; i < a.size(); i++){
      |                 ~~^~~~~~~~~~
meetings.cpp:52:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   for(ll i = 1; i < nodes.size(); i++){
      |                 ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 0 ms 336 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 0 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 0 ms 336 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 0 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 0 ms 336 KB Output is correct
19 Correct 0 ms 336 KB Output is correct
20 Correct 0 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 0 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 0 ms 336 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 0 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 0 ms 336 KB Output is correct
19 Correct 0 ms 336 KB Output is correct
20 Correct 0 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 0 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 4 ms 432 KB Output is correct
28 Correct 4 ms 336 KB Output is correct
29 Correct 4 ms 336 KB Output is correct
30 Correct 3 ms 336 KB Output is correct
31 Correct 3 ms 432 KB Output is correct
32 Correct 4 ms 336 KB Output is correct
33 Correct 8 ms 464 KB Output is correct
34 Correct 9 ms 444 KB Output is correct
35 Correct 8 ms 464 KB Output is correct
36 Correct 3 ms 336 KB Output is correct
37 Correct 9 ms 464 KB Output is correct
38 Correct 7 ms 440 KB Output is correct
39 Correct 6 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 205 ms 704 KB Output is correct
2 Correct 300 ms 668 KB Output is correct
3 Correct 307 ms 620 KB Output is correct
4 Correct 268 ms 712 KB Output is correct
5 Correct 180 ms 608 KB Output is correct
6 Correct 196 ms 656 KB Output is correct
7 Correct 424 ms 604 KB Output is correct
8 Correct 448 ms 760 KB Output is correct
9 Correct 525 ms 672 KB Output is correct
10 Correct 438 ms 744 KB Output is correct
11 Correct 509 ms 620 KB Output is correct
12 Correct 292 ms 712 KB Output is correct
13 Correct 212 ms 668 KB Output is correct
14 Correct 278 ms 756 KB Output is correct
15 Correct 219 ms 632 KB Output is correct
16 Correct 260 ms 652 KB Output is correct
17 Correct 438 ms 764 KB Output is correct
18 Correct 231 ms 648 KB Output is correct
19 Correct 256 ms 740 KB Output is correct
20 Correct 265 ms 728 KB Output is correct
21 Correct 308 ms 712 KB Output is correct
22 Correct 260 ms 768 KB Output is correct
23 Correct 235 ms 648 KB Output is correct
24 Correct 258 ms 608 KB Output is correct
25 Correct 226 ms 644 KB Output is correct
26 Correct 256 ms 664 KB Output is correct
27 Correct 251 ms 660 KB Output is correct
28 Correct 536 ms 604 KB Output is correct
29 Correct 446 ms 680 KB Output is correct
30 Correct 413 ms 648 KB Output is correct
31 Correct 442 ms 756 KB Output is correct
32 Correct 550 ms 744 KB Output is correct
33 Correct 558 ms 856 KB Output is correct
34 Correct 3 ms 336 KB Output is correct
35 Correct 3 ms 336 KB Output is correct
36 Correct 4 ms 336 KB Output is correct
37 Correct 4 ms 336 KB Output is correct
38 Correct 3 ms 336 KB Output is correct
39 Correct 4 ms 336 KB Output is correct
40 Correct 7 ms 336 KB Output is correct
41 Correct 9 ms 440 KB Output is correct
42 Correct 9 ms 336 KB Output is correct
43 Correct 3 ms 336 KB Output is correct
44 Correct 9 ms 448 KB Output is correct
45 Correct 8 ms 464 KB Output is correct
46 Correct 4 ms 464 KB Output is correct
47 Correct 0 ms 336 KB Output is correct
48 Correct 0 ms 336 KB Output is correct
49 Correct 0 ms 336 KB Output is correct
50 Correct 0 ms 336 KB Output is correct
51 Correct 0 ms 336 KB Output is correct
52 Correct 0 ms 336 KB Output is correct
53 Correct 1 ms 336 KB Output is correct
54 Correct 1 ms 336 KB Output is correct
55 Correct 0 ms 336 KB Output is correct
56 Correct 0 ms 336 KB Output is correct
57 Correct 0 ms 336 KB Output is correct
58 Correct 0 ms 336 KB Output is correct
59 Correct 1 ms 336 KB Output is correct
60 Correct 0 ms 336 KB Output is correct
61 Correct 0 ms 336 KB Output is correct
62 Correct 0 ms 336 KB Output is correct
63 Correct 0 ms 336 KB Output is correct
64 Correct 0 ms 336 KB Output is correct
65 Correct 0 ms 336 KB Output is correct
66 Correct 0 ms 336 KB Output is correct
67 Correct 0 ms 336 KB Output is correct
68 Correct 0 ms 336 KB Output is correct
69 Correct 0 ms 336 KB Output is correct
70 Correct 0 ms 336 KB Output is correct
71 Correct 1 ms 336 KB Output is correct
72 Correct 0 ms 336 KB Output is correct