Submission #789479

# Submission time Handle Problem Language Result Execution time Memory
789479 2023-07-21T12:39:37 Z someone Two Transportations (JOI19_transportations) C++14
0 / 100
371 ms 13324 KB
#include <bits/stdc++.h>
#include "Azer.h"
using namespace std;
 
struct Arc {
    int nex, pds;
};
 
const int N = 2e3 + 42, INF = 1e6 + 42;
 
bool sent[N];
int n, knows[N];
vector<bool> msg;
vector<int> dist;
vector<Arc> arc[N];
priority_queue<pair<int, int>> pq;
 
void InitA(int X, int a, vector<int> U, vector<int> V, vector<int> C) {
    n = X;
    dist.resize(n);
    for(int i = 0; i < a; i++) {
        arc[U[i]].push_back({V[i], C[i]});
        arc[V[i]].push_back({U[i], C[i]});
    }
    for(int i = 1; i < n; i++)
        knows[i] = dist[i] = INF;
    for(int i = 0; i < n; i++)
        pq.push({-dist[i], i});
 
    bool envoi = false;
    while(!envoi && !pq.empty()) {
        int i = pq.top().second,
            d = -pq.top().first;
        pq.pop();
        if(dist[i] == d) {
            for(Arc a : arc[i]) {
                if(dist[a.nex] > dist[i] + a.pds) {
                    dist[a.nex] = dist[i] + a.pds;
                    pq.push({-dist[a.nex], a.nex});
                }
            }
            if(!sent[i]) {
                //cout << "Azer envoie " << i << ' ' << d << '\n';
                sent[i] = true;
                envoi = true;
                for(int j = 0; j < 11; j++)
                    SendA(i & (1 << j));
                for(int j = 0; j < 20; j++)
                    SendA(d & (1 << j));
            }
        }
    }
}
 
void ReceiveA(bool x) {
    msg.push_back(x);
    if(31 == (int)msg.size()) {
        int i = 0, d = 0;
        for(int j = 0; j < 11; j++)
            i += (1 << j) * msg[j];
        for(int j = 0; j < 20; j++)
            d += (1 << j) * msg[j + 11];
        msg.clear();
 
      	if(d < dist[i])
          	pq.push({-d, i});
        dist[i] = min(dist[i], d);
        
        knows[i] = d;
 
        bool envoi = false;
        while(!envoi && !pq.empty()) {
            i = pq.top().second,
            d = -pq.top().first;
            pq.pop();
            if(dist[i] == d) {
                for(Arc a : arc[i]) {
                    if(dist[a.nex] > dist[i] + a.pds) {
                        dist[a.nex] = dist[i] + a.pds;
                        pq.push({-dist[a.nex], a.nex});
                    }
                }
                if(!sent[i] && knows[i] > d) {
                    //cout << "Azer envoie " << i << ' ' << d << '\n';
                    knows[i] = d;
                    sent[i] = true;
                    envoi = true;
                    for(int j = 0; j < 11; j++)
                        SendA(i & (1 << j));
                    for(int j = 0; j < 20; j++)
                        SendA(d & (1 << j));
                }
            }
        }
        if(!envoi)
            for(int j = 0; j < n; j++)
                if(dist[j] == INF) {
                    for(int k = 0; k < 11; k++)
                        SendA(j & (1 << k));
                    for(int k = 0; k < 20; k++)
                        SendA(INF & (1 << k));
                  j = n;
                }
    }
}
 
vector<int> Answer() {
    return dist;
}
#include <bits/stdc++.h>
#include "Baijan.h"
using namespace std;
 
struct Arc {
    int nex, pds;
};
 
const int N = 2e3 + 42, INF = 1e6 + 42;
 
bool sent[N];
int n, knows[N];
vector<int> dist;
vector<Arc> arc[N];
vector<bool> msg;
priority_queue<pair<int, int>> pq;
 
void InitB(int X, int b, vector<int> S, vector<int> T, vector<int> D) {
    n = X;
    dist.resize(n);
    for(int i = 0; i < b; i++) {
        arc[S[i]].push_back({T[i], D[i]});
        arc[T[i]].push_back({S[i], D[i]});
    }
    for(int i = 1; i < n; i++)
        knows[i] = dist[i] = INF;
    for(int i = 0; i < n; i++)
        pq.push({-dist[i], i});
}
 
void ReceiveB(bool y) {
    msg.push_back(y);
    if(31 == (int)msg.size()) {
        int i = 0, d = 0;
        for(int j = 0; j < 11; j++)
            i += (1 << j) * msg[j];
        for(int j = 0; j < 20; j++)
            d += (1 << j) * msg[j + 11];
        msg.clear();
 
      	if(dist[i] > d)
        	pq.push({-d, i});
        dist[i] = min(dist[i], d);
        knows[i] = d;
 
        bool envoi = false;
        while(!envoi && !pq.empty()) {
            i = pq.top().second,
            d = -pq.top().first;
            pq.pop();
            if(dist[i] == d) {
                for(Arc a : arc[i]) {
                    if(dist[a.nex] > dist[i] + a.pds) {
                        dist[a.nex] = dist[i] + a.pds;
                        pq.push({-dist[a.nex], a.nex});
                    }
                }
                if(!sent[i] && knows[i] > d) {
                    knows[i] = d;
                    //cout << "Baijan envoie " << i << ' ' << d << '\n';
                    sent[i] = true;
                    envoi = true;
                    for(int j = 0; j < 11; j++)
                        SendB(i & (1 << j));
                    for(int j = 0; j < 20; j++)
                        SendB(d & (1 << j));
                }
            }
        }
        if(!envoi)
            for(int j = 0; j < n; j++)
                if(dist[j] == INF) {
                    for(int k = 0; k < 11; k++)
                        SendB(j & (1 << k));
                    for(int k = 0; k < 20; k++)
                        SendB(INF & (1 << k));
                  j = n;
                }
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 236 ms 380 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 656 KB Output is correct
2 Incorrect 172 ms 456 KB Wrong Answer [2]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 167 ms 460 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 207 ms 712 KB Output is correct
2 Correct 371 ms 760 KB Output is correct
3 Correct 321 ms 13324 KB Output is correct
4 Incorrect 323 ms 656 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 207 ms 712 KB Output is correct
2 Correct 371 ms 760 KB Output is correct
3 Correct 321 ms 13324 KB Output is correct
4 Incorrect 323 ms 656 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 207 ms 712 KB Output is correct
2 Correct 371 ms 760 KB Output is correct
3 Correct 321 ms 13324 KB Output is correct
4 Incorrect 323 ms 656 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 236 ms 380 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -