Submission #851096

# Submission time Handle Problem Language Result Execution time Memory
851096 2023-09-18T13:56:01 Z 1zaid1 Meetings (JOI19_meetings) C++17
29 / 100
494 ms 1112 KB
#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

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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 528 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 528 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 528 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 596 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 4 ms 344 KB Output is correct
28 Correct 4 ms 344 KB Output is correct
29 Correct 4 ms 572 KB Output is correct
30 Correct 3 ms 344 KB Output is correct
31 Correct 3 ms 344 KB Output is correct
32 Correct 5 ms 344 KB Output is correct
33 Correct 7 ms 344 KB Output is correct
34 Correct 9 ms 344 KB Output is correct
35 Correct 8 ms 600 KB Output is correct
36 Correct 4 ms 344 KB Output is correct
37 Correct 10 ms 344 KB Output is correct
38 Correct 8 ms 600 KB Output is correct
39 Correct 8 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 221 ms 600 KB Output is correct
2 Correct 306 ms 600 KB Output is correct
3 Correct 346 ms 848 KB Output is correct
4 Correct 261 ms 600 KB Output is correct
5 Correct 217 ms 600 KB Output is correct
6 Correct 189 ms 716 KB Output is correct
7 Correct 372 ms 600 KB Output is correct
8 Correct 466 ms 716 KB Output is correct
9 Correct 494 ms 788 KB Output is correct
10 Correct 432 ms 776 KB Output is correct
11 Runtime error 2 ms 1112 KB Execution killed with signal 6
12 Halted 0 ms 0 KB -