Submission #954416

# Submission time Handle Problem Language Result Execution time Memory
954416 2024-03-27T20:31:50 Z efishel Airline Route Map (JOI18_airline) C++17
37 / 100
2500 ms 40956 KB
#include "Alicelib.h"
#include <cassert>
#include <cstdio>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
using ll = long long;
using vll = vector <ll>;

void Alice (int n, int m, int A[], int B[]) {
    bool mat[n][n]{};
    for (ll i = 0; i < m; i++) {
        mat[A[i]][B[i]] = true;
        mat[B[i]][A[i]] = true;
    }
    vector <bool> th;
    for (ll i = 0; i < n; i++) {
        for (ll j = i; j < n; j++) {
            th.push_back(mat[i][j]);
        }
    }
    vector <pair <ll, ll> > egs;
    for (ll i = 0; i < th.size(); i++) {
        egs.push_back({ i, i+1 });
        if (th[i]) egs.push_back({ 0, i+1 });
    }
    for (auto [u, v] : egs) cerr << u << ' ' << v << '\n';
    InitG(th.size()+1+6, egs.size()+9);
    ll i=th.size()+2;
    for (ll j = 0; j < 4; j++) egs.push_back({ i+j, i+j+1 });
    for (ll j = i; j < i+5; j++) egs.push_back({ 0, j });
    ll timer=0;
    for (auto [u, v] : egs) MakeG(timer++, u, v);
}
#include "Boblib.h"
#include <cassert>
#include <cstdio>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
using ll = long long;
using vll = vector <ll>;

const ll MAXN = 1E6+16;
vll adj[MAXN];

void Bob (int n, int m, int A[], int B[]) {
    cerr << "BOB\n";
    for (ll i = 0; i < m; i++) {
        adj[A[i]].push_back(B[i]);
        adj[B[i]].push_back(A[i]);
        cerr << A[i] << ' ' << B[i] << '\n';
    }
    cerr << "\n";
    ll sp = -15, best=0;
    ll nd = -15;
    for (ll i = 0; i < n; i++) {
        if (adj[i].size() > best) best = adj[i].size(), sp = i;
        if (adj[i].size() == 1) nd = i;
    }
    cerr << "special: " << sp << '\n';
    cerr << "end: " << nd << '\n';
    vector <bool> th;
    function <void(ll, ll)> dfs = [&](ll u, ll par) {
        bool has1 = false;
        for (ll v : adj[u]) {
            if (v == sp) { has1 = true; continue; }
            if (v == par) continue;
            dfs(v, u);
        }
        th.push_back(has1);
    };
    dfs(nd, nd);
    ll nn = 0;
    while (nn*(nn+1)/2 < th.size()) nn++;
    bool mat[nn][nn]{};
    ll c = 0;
    vector <pair <ll, ll> > egs;
    for (ll i = 0; i < nn; i++) {
        for (ll j = i; j < nn; j++) {
            if (th[c++] && !(i==0 && j==0)) egs.push_back({ i, j });
        }
    }
    for (auto [u, v] : egs) cerr << u << ' ' << v << '\n';
    InitMap(nn, egs.size());
    for (auto [u, v] : egs) MakeMap(u, v);
}

Compilation message

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:23:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (ll i = 0; i < th.size(); i++) {
      |                    ~~^~~~~~~~~~~

Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:24:27: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   24 |         if (adj[i].size() > best) best = adj[i].size(), sp = i;
      |             ~~~~~~~~~~~~~~^~~~~~
Bob.cpp:41:24: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     while (nn*(nn+1)/2 < th.size()) nn++;
      |            ~~~~~~~~~~~~^~~~~~~~~~~
Bob.cpp:42:10: warning: unused variable 'mat' [-Wunused-variable]
   42 |     bool mat[nn][nn]{};
      |          ^~~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 40412 KB Output is correct
2 Correct 12 ms 40280 KB Output is correct
3 Correct 8 ms 40284 KB Output is correct
4 Correct 9 ms 38400 KB Output is correct
5 Correct 8 ms 40444 KB Output is correct
6 Correct 9 ms 40452 KB Output is correct
7 Correct 8 ms 40452 KB Output is correct
8 Correct 10 ms 40452 KB Output is correct
9 Correct 8 ms 40452 KB Output is correct
10 Correct 12 ms 38584 KB Output is correct
11 Correct 9 ms 40448 KB Output is correct
12 Correct 9 ms 40456 KB Output is correct
13 Correct 9 ms 40452 KB Output is correct
14 Correct 9 ms 40452 KB Output is correct
15 Correct 8 ms 40456 KB Output is correct
16 Correct 9 ms 40452 KB Output is correct
17 Correct 10 ms 40452 KB Output is correct
18 Correct 10 ms 40460 KB Output is correct
19 Correct 9 ms 40604 KB Output is correct
20 Correct 9 ms 40452 KB Output is correct
21 Correct 9 ms 40452 KB Output is correct
22 Correct 9 ms 40312 KB Output is correct
23 Correct 10 ms 40452 KB Output is correct
24 Correct 8 ms 38400 KB Output is correct
25 Correct 8 ms 40452 KB Output is correct
26 Correct 8 ms 40448 KB Output is correct
27 Correct 10 ms 40452 KB Output is correct
28 Correct 8 ms 40700 KB Output is correct
29 Correct 9 ms 40444 KB Output is correct
30 Correct 13 ms 38372 KB Output is correct
31 Correct 7 ms 38404 KB Output is correct
32 Correct 8 ms 38376 KB Output is correct
33 Correct 9 ms 38404 KB Output is correct
34 Correct 9 ms 38404 KB Output is correct
35 Correct 9 ms 38408 KB Output is correct
36 Correct 9 ms 40448 KB Output is correct
37 Correct 11 ms 40248 KB Output is correct
38 Correct 9 ms 40452 KB Output is correct
39 Correct 9 ms 40448 KB Output is correct
40 Correct 9 ms 40448 KB Output is correct
41 Correct 11 ms 40448 KB Output is correct
42 Correct 9 ms 40460 KB Output is correct
43 Correct 9 ms 40448 KB Output is correct
44 Correct 8 ms 38404 KB Output is correct
45 Correct 9 ms 38404 KB Output is correct
46 Correct 10 ms 40364 KB Output is correct
47 Correct 10 ms 40452 KB Output is correct
48 Correct 9 ms 40456 KB Output is correct
49 Correct 9 ms 40452 KB Output is correct
50 Correct 8 ms 38400 KB Output is correct
51 Correct 8 ms 38408 KB Output is correct
52 Correct 9 ms 40448 KB Output is correct
53 Correct 7 ms 38404 KB Output is correct
54 Correct 9 ms 40380 KB Output is correct
55 Correct 8 ms 40448 KB Output is correct
56 Correct 9 ms 40448 KB Output is correct
57 Correct 8 ms 40368 KB Output is correct
58 Correct 8 ms 40700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 40412 KB Output is correct
2 Correct 12 ms 40280 KB Output is correct
3 Correct 8 ms 40284 KB Output is correct
4 Correct 9 ms 38400 KB Output is correct
5 Correct 8 ms 40444 KB Output is correct
6 Correct 9 ms 40452 KB Output is correct
7 Correct 8 ms 40452 KB Output is correct
8 Correct 10 ms 40452 KB Output is correct
9 Correct 8 ms 40452 KB Output is correct
10 Correct 12 ms 38584 KB Output is correct
11 Correct 9 ms 40448 KB Output is correct
12 Correct 9 ms 40456 KB Output is correct
13 Correct 9 ms 40452 KB Output is correct
14 Correct 9 ms 40452 KB Output is correct
15 Correct 8 ms 40456 KB Output is correct
16 Correct 9 ms 40452 KB Output is correct
17 Correct 10 ms 40452 KB Output is correct
18 Correct 10 ms 40460 KB Output is correct
19 Correct 9 ms 40604 KB Output is correct
20 Correct 9 ms 40452 KB Output is correct
21 Correct 9 ms 40452 KB Output is correct
22 Correct 9 ms 40312 KB Output is correct
23 Correct 10 ms 40452 KB Output is correct
24 Correct 8 ms 38400 KB Output is correct
25 Correct 8 ms 40452 KB Output is correct
26 Correct 8 ms 40448 KB Output is correct
27 Correct 10 ms 40452 KB Output is correct
28 Correct 8 ms 40700 KB Output is correct
29 Correct 9 ms 40444 KB Output is correct
30 Correct 13 ms 38372 KB Output is correct
31 Correct 7 ms 38404 KB Output is correct
32 Correct 8 ms 38376 KB Output is correct
33 Correct 9 ms 38404 KB Output is correct
34 Correct 9 ms 38404 KB Output is correct
35 Correct 9 ms 38408 KB Output is correct
36 Correct 9 ms 40448 KB Output is correct
37 Correct 11 ms 40248 KB Output is correct
38 Correct 9 ms 40452 KB Output is correct
39 Correct 9 ms 40448 KB Output is correct
40 Correct 9 ms 40448 KB Output is correct
41 Correct 11 ms 40448 KB Output is correct
42 Correct 9 ms 40460 KB Output is correct
43 Correct 9 ms 40448 KB Output is correct
44 Correct 8 ms 38404 KB Output is correct
45 Correct 9 ms 38404 KB Output is correct
46 Correct 10 ms 40364 KB Output is correct
47 Correct 10 ms 40452 KB Output is correct
48 Correct 9 ms 40456 KB Output is correct
49 Correct 9 ms 40452 KB Output is correct
50 Correct 8 ms 38400 KB Output is correct
51 Correct 8 ms 38408 KB Output is correct
52 Correct 9 ms 40448 KB Output is correct
53 Correct 7 ms 38404 KB Output is correct
54 Correct 9 ms 40380 KB Output is correct
55 Correct 8 ms 40448 KB Output is correct
56 Correct 9 ms 40448 KB Output is correct
57 Correct 8 ms 40368 KB Output is correct
58 Correct 8 ms 40700 KB Output is correct
59 Correct 26 ms 40576 KB Output is correct
60 Correct 28 ms 40528 KB Output is correct
61 Correct 22 ms 40412 KB Output is correct
62 Correct 15 ms 40448 KB Output is correct
63 Correct 17 ms 40452 KB Output is correct
64 Correct 23 ms 40444 KB Output is correct
65 Correct 26 ms 40500 KB Output is correct
66 Correct 24 ms 40448 KB Output is correct
67 Correct 21 ms 40504 KB Output is correct
68 Correct 17 ms 40956 KB Output is correct
69 Correct 18 ms 40452 KB Output is correct
70 Correct 21 ms 40444 KB Output is correct
71 Correct 25 ms 40452 KB Output is correct
72 Correct 26 ms 40452 KB Output is correct
73 Correct 21 ms 40452 KB Output is correct
74 Correct 24 ms 40444 KB Output is correct
75 Correct 17 ms 40452 KB Output is correct
76 Correct 21 ms 40444 KB Output is correct
77 Correct 24 ms 40564 KB Output is correct
78 Correct 26 ms 40740 KB Output is correct
79 Correct 19 ms 40452 KB Output is correct
80 Correct 17 ms 40452 KB Output is correct
81 Correct 15 ms 40528 KB Output is correct
82 Correct 13 ms 40512 KB Output is correct
83 Correct 14 ms 40452 KB Output is correct
84 Correct 18 ms 40476 KB Output is correct
85 Correct 23 ms 40568 KB Output is correct
86 Correct 19 ms 40452 KB Output is correct
87 Correct 16 ms 40452 KB Output is correct
88 Correct 13 ms 40452 KB Output is correct
89 Correct 17 ms 38404 KB Output is correct
90 Correct 15 ms 38396 KB Output is correct
91 Correct 15 ms 38404 KB Output is correct
92 Correct 17 ms 38528 KB Output is correct
93 Correct 16 ms 38400 KB Output is correct
94 Correct 26 ms 40452 KB Output is correct
95 Correct 27 ms 40468 KB Output is correct
96 Correct 26 ms 40944 KB Output is correct
97 Correct 26 ms 40452 KB Output is correct
98 Correct 28 ms 40452 KB Output is correct
99 Correct 24 ms 40708 KB Output is correct
100 Correct 20 ms 40452 KB Output is correct
101 Correct 16 ms 40444 KB Output is correct
102 Correct 15 ms 38408 KB Output is correct
103 Correct 15 ms 40452 KB Output is correct
104 Correct 16 ms 40452 KB Output is correct
105 Correct 22 ms 40428 KB Output is correct
106 Correct 20 ms 40540 KB Output is correct
107 Correct 16 ms 40452 KB Output is correct
108 Correct 15 ms 40452 KB Output is correct
109 Correct 22 ms 40536 KB Output is correct
110 Correct 12 ms 40452 KB Output is correct
111 Correct 17 ms 40576 KB Output is correct
112 Correct 17 ms 40444 KB Output is correct
113 Correct 14 ms 40452 KB Output is correct
114 Correct 15 ms 40784 KB Output is correct
115 Correct 20 ms 40636 KB Output is correct
116 Correct 11 ms 40452 KB Output is correct
117 Correct 18 ms 40452 KB Output is correct
118 Correct 17 ms 40556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3083 ms 34288 KB Time limit exceeded
2 Halted 0 ms 0 KB -