Submission #927602

# Submission time Handle Problem Language Result Execution time Memory
927602 2024-02-15T07:07:05 Z Tuanlinh123 Amusement Park (JOI17_amusement_park) C++17
100 / 100
40 ms 25072 KB
#include "Joi.h"
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

void Joi(int n, int m, int u[], int v[], ll x, int t) 
{
    vector <vector <ll>> A(n);
    for (ll i=0; i<m; i++)
        A[u[i]].pb(v[i]), A[v[i]].pb(u[i]);
    vector <vector <ll>> order(n);
    vector <ll> col(n, -1);
    auto getfirst60=[&]()
    {
        ll cnt=0;
        function<void(ll)> dfs=[&](ll u)
        {
            if (cnt>=60) return;
            col[u]=cnt++;
            for (ll v:A[u])
                if (col[v]==-1)
                    dfs(v);
        }; dfs(0);
        vector <bool> check(n, 0);
        function<void(ll, ll)> dfs1=[&](ll u, ll r)
        {
            check[u]=1, order[r].pb(u);
            for (ll v:A[u])
                if (!check[v] && col[v]>=0)
                    dfs1(v, r), order[r].pb(u);
        };
        for (ll i=0; i<n; i++) if (col[i]>=0)
            check.assign(n, 0), dfs1(i, i), order[i].erase(order[i].begin());
    }; getfirst60();
    queue <ll> q;
    for (ll i=0; i<n; i++)
        if (col[i]>=0) q.push(i);
    while (!q.empty())
    {
        ll u=q.front(); q.pop();
        for (ll v:A[u]) if (col[v]==-1)
        {
            col[v]=col[order[u].back()], order[v].pb(u), q.push(v);
            for (ll j:order[u]) order[v].pb(j); order[v].pop_back();
        }
    }
    for (ll i=0; i<n; i++) MessageBoard(i, (x>>col[i])&1);
}
#include "Ioi.h"
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

ll Ioi(int n, int m, int u[], int v[], int p, int cr, int t) 
{
    vector <vector <ll>> A(n);
    for (ll i=0; i<m; i++)
        A[u[i]].pb(v[i]), A[v[i]].pb(u[i]);
    vector <vector <ll>> order(n);
    vector <ll> col(n, -1);
    auto getfirst60=[&]()
    {
        ll cnt=0;
        function<void(ll)> dfs=[&](ll u)
        {
            if (cnt>=60) return;
            col[u]=cnt++;
            for (ll v:A[u])
                if (col[v]==-1)
                    dfs(v);
        }; dfs(0);
        vector <bool> check(n, 0);
        function<void(ll, ll)> dfs1=[&](ll u, ll r)
        {
            check[u]=1;
            if (u!=r) order[r].pb(u);
            for (ll v:A[u])
                if (!check[v] && col[v]>=0)
                    dfs1(v, r), order[r].pb(u);
        };
        for (ll i=0; i<n; i++) if (col[i]>=0)
            check.assign(n, 0), dfs1(i, i);
    }; getfirst60();
    queue <ll> q;
    for (ll i=0; i<n; i++)
        if (col[i]>=0) q.push(i);
    while (!q.empty())
    {
        ll u=q.front(); q.pop();
        for (ll v:A[u]) if (col[v]==-1)
        {
            col[v]=col[order[u].back()], order[v].pb(u), q.push(v);
            for (ll j:order[u]) order[v].pb(j); order[v].pop_back();
        }
    }
    ll ans=(ll)cr<<col[p];
    for (ll i:order[p]) ans|=(ll)Move(i)<<col[i];
    return ans;
}

Compilation message

Joi.cpp: In function 'void Joi(int, int, int*, int*, long long int, int)':
Joi.cpp:50:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   50 |             for (ll j:order[u]) order[v].pb(j); order[v].pop_back();
      |             ^~~
Joi.cpp:50:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   50 |             for (ll j:order[u]) order[v].pb(j); order[v].pop_back();
      |                                                 ^~~~~

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:51:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   51 |             for (ll j:order[u]) order[v].pb(j); order[v].pop_back();
      |             ^~~
Ioi.cpp:51:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   51 |             for (ll j:order[u]) order[v].pb(j); order[v].pop_back();
      |                                                 ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 796 KB Output is correct
2 Correct 1 ms 1304 KB Output is correct
3 Correct 2 ms 1308 KB Output is correct
4 Correct 0 ms 796 KB Output is correct
5 Correct 1 ms 792 KB Output is correct
6 Correct 2 ms 1292 KB Output is correct
7 Correct 2 ms 1308 KB Output is correct
8 Correct 2 ms 1296 KB Output is correct
9 Correct 2 ms 1296 KB Output is correct
10 Correct 1 ms 1300 KB Output is correct
11 Correct 5 ms 1644 KB Output is correct
12 Correct 1 ms 784 KB Output is correct
13 Correct 2 ms 1316 KB Output is correct
14 Correct 2 ms 1316 KB Output is correct
15 Correct 2 ms 1312 KB Output is correct
16 Correct 2 ms 1316 KB Output is correct
17 Correct 2 ms 1488 KB Output is correct
18 Correct 2 ms 1360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 24696 KB Output is correct
2 Correct 35 ms 24584 KB Output is correct
3 Correct 39 ms 24696 KB Output is correct
4 Correct 27 ms 23532 KB Output is correct
5 Correct 31 ms 23724 KB Output is correct
6 Correct 27 ms 23400 KB Output is correct
7 Correct 27 ms 23496 KB Output is correct
8 Correct 33 ms 23532 KB Output is correct
9 Correct 30 ms 23592 KB Output is correct
10 Correct 28 ms 23904 KB Output is correct
11 Correct 30 ms 23604 KB Output is correct
12 Correct 27 ms 21832 KB Output is correct
13 Correct 26 ms 21812 KB Output is correct
14 Correct 31 ms 22860 KB Output is correct
15 Correct 27 ms 23548 KB Output is correct
16 Correct 32 ms 23620 KB Output is correct
17 Correct 27 ms 23636 KB Output is correct
18 Correct 28 ms 23584 KB Output is correct
19 Correct 26 ms 23616 KB Output is correct
20 Correct 24 ms 23640 KB Output is correct
21 Correct 24 ms 23348 KB Output is correct
22 Correct 28 ms 24152 KB Output is correct
23 Correct 30 ms 24044 KB Output is correct
24 Correct 30 ms 23876 KB Output is correct
25 Correct 30 ms 24140 KB Output is correct
26 Correct 33 ms 23780 KB Output is correct
27 Correct 30 ms 23884 KB Output is correct
28 Correct 31 ms 24060 KB Output is correct
29 Correct 27 ms 21824 KB Output is correct
30 Correct 30 ms 22860 KB Output is correct
31 Correct 1 ms 1144 KB Output is correct
32 Correct 2 ms 1292 KB Output is correct
33 Correct 2 ms 1308 KB Output is correct
34 Correct 1 ms 1312 KB Output is correct
35 Correct 1 ms 800 KB Output is correct
36 Correct 1 ms 788 KB Output is correct
37 Correct 1 ms 800 KB Output is correct
38 Correct 0 ms 800 KB Output is correct
39 Correct 1 ms 796 KB Output is correct
40 Correct 2 ms 800 KB Output is correct
41 Correct 1 ms 780 KB Output is correct
42 Correct 1 ms 796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 792 KB Output is correct
2 Correct 1 ms 788 KB Output is correct
3 Correct 1 ms 796 KB Output is correct
4 Correct 4 ms 4404 KB Output is correct
5 Correct 4 ms 4412 KB Output is correct
6 Correct 4 ms 4412 KB Output is correct
7 Correct 6 ms 4712 KB Output is correct
8 Correct 5 ms 4412 KB Output is correct
9 Correct 25 ms 23024 KB Output is correct
10 Correct 24 ms 23024 KB Output is correct
11 Correct 24 ms 23032 KB Output is correct
12 Correct 1 ms 796 KB Output is correct
13 Correct 0 ms 796 KB Output is correct
14 Correct 1 ms 796 KB Output is correct
15 Correct 1 ms 784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 24460 KB Output is correct
2 Correct 34 ms 24904 KB Output is correct
3 Correct 36 ms 24708 KB Output is correct
4 Correct 30 ms 23520 KB Output is correct
5 Correct 30 ms 23436 KB Output is correct
6 Correct 27 ms 23536 KB Output is correct
7 Correct 31 ms 23616 KB Output is correct
8 Correct 30 ms 23520 KB Output is correct
9 Correct 27 ms 23628 KB Output is correct
10 Correct 28 ms 23876 KB Output is correct
11 Correct 30 ms 23880 KB Output is correct
12 Correct 30 ms 21824 KB Output is correct
13 Correct 28 ms 21772 KB Output is correct
14 Correct 28 ms 22848 KB Output is correct
15 Correct 28 ms 23624 KB Output is correct
16 Correct 28 ms 23632 KB Output is correct
17 Correct 27 ms 23640 KB Output is correct
18 Correct 36 ms 23656 KB Output is correct
19 Correct 27 ms 23568 KB Output is correct
20 Correct 25 ms 23888 KB Output is correct
21 Correct 25 ms 23364 KB Output is correct
22 Correct 31 ms 23776 KB Output is correct
23 Correct 30 ms 23896 KB Output is correct
24 Correct 30 ms 23820 KB Output is correct
25 Correct 33 ms 23860 KB Output is correct
26 Correct 32 ms 23752 KB Output is correct
27 Correct 32 ms 23872 KB Output is correct
28 Correct 28 ms 23876 KB Output is correct
29 Correct 27 ms 21824 KB Output is correct
30 Correct 34 ms 22840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 24764 KB Output is correct
2 Correct 40 ms 24932 KB Output is correct
3 Correct 40 ms 25072 KB Output is correct
4 Correct 28 ms 23532 KB Output is correct
5 Correct 27 ms 23620 KB Output is correct
6 Correct 27 ms 23632 KB Output is correct
7 Correct 27 ms 23644 KB Output is correct
8 Correct 27 ms 23640 KB Output is correct
9 Correct 33 ms 23740 KB Output is correct
10 Correct 32 ms 24016 KB Output is correct
11 Correct 32 ms 23876 KB Output is correct
12 Correct 27 ms 21812 KB Output is correct
13 Correct 26 ms 21976 KB Output is correct
14 Correct 27 ms 22852 KB Output is correct
15 Correct 30 ms 23972 KB Output is correct
16 Correct 35 ms 23888 KB Output is correct
17 Correct 27 ms 23644 KB Output is correct
18 Correct 27 ms 23536 KB Output is correct
19 Correct 28 ms 23736 KB Output is correct
20 Correct 26 ms 23616 KB Output is correct
21 Correct 27 ms 23388 KB Output is correct
22 Correct 35 ms 23996 KB Output is correct
23 Correct 40 ms 23820 KB Output is correct
24 Correct 30 ms 23828 KB Output is correct
25 Correct 30 ms 23856 KB Output is correct
26 Correct 33 ms 23876 KB Output is correct
27 Correct 31 ms 23896 KB Output is correct
28 Correct 28 ms 23776 KB Output is correct
29 Correct 28 ms 21820 KB Output is correct
30 Correct 28 ms 22580 KB Output is correct
31 Correct 2 ms 1312 KB Output is correct
32 Correct 2 ms 1312 KB Output is correct
33 Correct 2 ms 1304 KB Output is correct
34 Correct 1 ms 1304 KB Output is correct
35 Correct 1 ms 788 KB Output is correct
36 Correct 1 ms 796 KB Output is correct
37 Correct 0 ms 788 KB Output is correct
38 Correct 0 ms 796 KB Output is correct
39 Correct 0 ms 796 KB Output is correct
40 Correct 1 ms 800 KB Output is correct
41 Correct 1 ms 788 KB Output is correct
42 Correct 1 ms 800 KB Output is correct