Submission #964559

# Submission time Handle Problem Language Result Execution time Memory
964559 2024-04-17T06:04:02 Z Tuanlinh123 Two Transportations (JOI19_transportations) C++17
6 / 100
442 ms 10448 KB
#include "Azer.h"
#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;

namespace A 
{
    const ll maxn=2005, inf=1<<20;

    vector <pll> A[maxn];
    ll n, last, cru, crd, crv, cnt, dis[maxn], check[maxn];

    void update(ll u)
    {
        check[u]=1, last=dis[u];
        for (auto [v, w]:A[u])
            dis[v]=min(dis[v], dis[u]+w);
    }

    void senddis()
    {
        ll big=-1;
        for (ll i=0; i<n; i++)
            if (!check[i] && (big==-1 || dis[i]<dis[big]))
                big=i;
        if (big==-1) return; cru=big;
        ll d=min(511, dis[big]-last); 
        for (ll i=0; i<9; i++) SendA(d>>i&1);
        // cout << "A sent distance: " << d << "\n";
    }
    void sendidx(ll idx) {
        // cout << "A sent index: " << idx << "\n";
        for (ll i=0; i<11; i++) SendA(idx>>i&1);}

    void init(ll N)
    {
        n=N, last=cru=crv=crd=cnt=0;
        for (ll i=0; i<n; i++) dis[i]=inf, check[i]=0;
        dis[0]=0, update(0), senddis();
    }
    
    void receive(bool x)
    {
        if (cnt<9)
        {
            if (x) crd^=1<<cnt;
            if (++cnt==9)
            {   
                crd+=last;
                if (crd>dis[cru])
                {
                    update(cru), sendidx(cru), senddis();
                    crd=cnt=0;
                }
                else crv=0;
            }
        }
        else
        {
            if (x) crv^=1<<cnt-9;
            if (++cnt==20)
            {
                dis[crv]=min(dis[crv], crd);
                update(crv), senddis(), cnt=crd=0;
            }
        }
    }
    
    vector <ll> answer()
    {
        vector <ll> ans(n);
        for (ll k=0; k<n; k++) ans[k]=dis[k];
        return ans;
    }
}

void ReceiveA(bool x) {A::receive(x);}
vector<int> Answer() {return A::answer();}
void InitA(int n, int a, vector<int> U, vector<int> V, vector<int> C) 
{
    for (ll i=0; i<a; i++)
    {
        A::A[U[i]].pb({V[i], C[i]}); 
        A::A[V[i]].pb({U[i], C[i]});
    }
    A::init(n);
}


#include "Baijan.h"
#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;

namespace B
{
    const ll maxn=2005, inf=1<<20;

    vector <pll> A[maxn];
    ll n, last, cru, crd, crv, cnt, dis[maxn], check[maxn];

    void update(ll u)
    {
        check[u]=1, last=dis[u];
        for (auto [v, w]:A[u])
            dis[v]=min(dis[v], dis[u]+w);
    }

    void senddis()
    {
        ll big=-1;
        for (ll i=0; i<n; i++)
            if (!check[i] && (big==-1 || dis[i]<dis[big]))
                big=i;
        if (big==-1) return; cru=big;
        ll d=min(511, dis[big]-last); 
        for (ll i=0; i<9; i++) SendB(d>>i&1);
        // cout << "A sent distance: " << d << "\n";
    }
    void sendidx(ll idx) {
        // cout << "A sent index: " << idx << "\n";
        for (ll i=0; i<11; i++) SendB(idx>>i&1);}

    void init(ll N)
    {
        n=N, last=cru=crv=crd=cnt=0;
        for (ll i=0; i<n; i++) dis[i]=inf, check[i]=0;
        dis[0]=0, update(0), senddis();
    }
    
    void receive(bool x)
    {
        if (cnt<9)
        {
            if (x) crd^=1<<cnt;
            if (++cnt==9)
            {   
                crd+=last;
                if (crd>dis[cru])
                {
                    update(cru), sendidx(cru), senddis();
                    crd=cnt=0;
                }
                else crv=0;
            }
        }
        else
        {
            if (x) crv^=1<<cnt-9;
            if (++cnt==20)
            {
                dis[crv]=min(dis[crv], crd);
                update(crv), senddis(), cnt=crd=0;
            }
        }
    }
}

void ReceiveB(bool x) {B::receive(x);}
void InitB(int n, int b, vector<int> U, vector<int> V, vector<int> C) 
{
    for (ll i=0; i<b; i++)
    {
        B::A[U[i]].pb({V[i], C[i]});
        B::A[V[i]].pb({U[i], C[i]});
    }
    B::init(n);
}

Compilation message

Azer.cpp: In function 'void A::senddis()':
Azer.cpp:33:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   33 |         if (big==-1) return; cru=big;
      |         ^~
Azer.cpp:33:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   33 |         if (big==-1) return; cru=big;
      |                              ^~~
Azer.cpp: In function 'void A::receive(bool)':
Azer.cpp:67:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   67 |             if (x) crv^=1<<cnt-9;
      |                            ~~~^~

Baijan.cpp: In function 'void B::senddis()':
Baijan.cpp:33:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   33 |         if (big==-1) return; cru=big;
      |         ^~
Baijan.cpp:33:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   33 |         if (big==-1) return; cru=big;
      |                              ^~~
Baijan.cpp: In function 'void B::receive(bool)':
Baijan.cpp:67:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   67 |             if (x) crv^=1<<cnt-9;
      |                            ~~~^~
# Verdict Execution time Memory Grader output
1 Correct 352 ms 1060 KB Output is correct
2 Correct 0 ms 664 KB Output is correct
3 Correct 368 ms 1060 KB Output is correct
4 Correct 442 ms 10448 KB Output is correct
5 Correct 19 ms 920 KB Output is correct
6 Correct 414 ms 2472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 664 KB Output is correct
2 Correct 397 ms 884 KB Output is correct
3 Incorrect 3 ms 964 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 352 ms 1060 KB Output is correct
2 Correct 0 ms 664 KB Output is correct
3 Correct 368 ms 1060 KB Output is correct
4 Correct 442 ms 10448 KB Output is correct
5 Correct 19 ms 920 KB Output is correct
6 Correct 414 ms 2472 KB Output is correct
7 Correct 1 ms 664 KB Output is correct
8 Correct 397 ms 884 KB Output is correct
9 Incorrect 3 ms 964 KB Output isn't correct
10 Halted 0 ms 0 KB -