Submission #122842

# Submission time Handle Problem Language Result Execution time Memory
122842 2019-06-29T10:56:58 Z Plurm Two Transportations (JOI19_transportations) C++14
Compilation error
0 ms 0 KB
#include "Azer.h"
#include <bits/stdc++.h>
using namespace std;

namespace {
    class state{
    public:
        int u;
        int w;
        state(int x, int y) : u(x), w(y) {}
        friend bool operator<(state x, state y){
            return x.w > y.w;
        }
    };
    int N;
    vector<pair<int, int> > g[2048];
    int dist[2048];
    vector<bool> cur;
    void computeShortestPath(){
        memset(dist, 0x3F, sizeof(dist));
        dist[0] = 0;
        priority_queue<state> pq;
        pq.emplace(0,0);
        while(!pq.empty()){
            state cur = pq.top();
            pq.pop();
            for(auto v : g[cur.u]){
                if(dist[v.first] > cur.w + v.second){
                    dist[v.first] = cur.w + v.second;
                    pq.emplace(v.first, dist[v.first]);
                }
            }
        }
    }
    int B = -1;
}

void InitA(int N, int A, vector<int> U, vector<int> V,
           vector<int> C) {
    ::N = N;
    for(int i = 0; i < A; i++){
        g[U[i]].emplace_back(V[i], C[i]);
        g[V[i]].emplace_back(U[i], C[i]);
    }
}

void ReceiveA(bool x) {
    cur.push_back(x);
    if(B == -1 && cur.size() == 10){
        B = 0;
        for(int i = 0; i < 10; i++){
            if(cur[i]) B += 1 << i;
        }
        cur.clear();
        return;
    }
    if(cur.size() % 31 == 0){
        int w = 0;
        for(int i = cur.size()-31; i < cur.size()-22; i++){
            if(cur[i]) w += 1 << (i-cur.size()+31);
        }
        int u = 0;
        for(int i = cur.size()-22; i < cur.size()-11; i++){
            if(cur[i]) u += 1 << (i-cur.size()+22);
        }
        int v = 0;
        for(int i = cur.size()-11; i < cur.size(); i++){
            if(cur[i]) v += 1 << (i-cur.size()+11);
        }
        g[u].emplace_back(v,w);
        g[v].emplace_back(u,w);
    }
    if(cur.size() == B * 31) computeShortestPath();
}

vector<int> Answer() {
    vector<int> ans;
    for(int i = 0; i < N; i++){
        ans.push_back(dist[i]);
    }
    return ans;
}
#include "Azer.h"
#include <bits/stdc++.h>
using namespace std;

namespace {
    class state{
    public:
        int u;
        int w;
        state(int x, int y) : u(x), w(y) {}
        friend bool operator<(state x, state y){
            return x.w > y.w;
        }
    };
    int N;
    vector<pair<int, int> > g[2048];
    int dist[2048];
    vector<bool> cur;
    void computeShortestPath(){
        for(int i = 1; i < N; i++){
            dist[i] = 1 << 20;
        }
        dist[0] = 0;
        priority_queue<state> pq;
        pq.emplace(0,0);
        while(!pq.empty()){
            state curr = pq.top();
            pq.pop();
            for(auto v : g[curr.u]){
                if(dist[v.first] > curr.w + v.second){
                    dist[v.first] = curr.w + v.second;
                    pq.emplace(v.first, dist[v.first]);
                }
            }
        }
    }
    int B = -1;
}

void InitA(int N, int A, vector<int> U, vector<int> V,
           vector<int> C) {
    ::N = N;
    for(int i = 0; i < A; i++){
        g[U[i]].emplace_back(V[i], C[i]);
        g[V[i]].emplace_back(U[i], C[i]);
    }
}

void ReceiveA(bool x) {
    cur.push_back(x);
    if(B == -1 && cur.size() == 10){
        B = 0;
        for(int i = 0; i < 10; i++){
            if(cur[i]) B += 1 << i;
        }
        cur.clear();
        return;
    }
    if(cur.size() % 31 == 0){
        int w = 0;
        for(int i = cur.size()-31; i < cur.size()-22; i++){
            if(cur[i]) w += 1 << (i-cur.size()+31);
        }
        int u = 0;
        for(int i = cur.size()-22; i < cur.size()-11; i++){
            if(cur[i]) u += 1 << (i-cur.size()+22);
        }
        int v = 0;
        for(int i = cur.size()-11; i < cur.size(); i++){
            if(cur[i]) v += 1 << (i-cur.size()+11);
        }
        g[u].emplace_back(v,w);
        g[v].emplace_back(u,w);
    }
    if(cur.size() == B * 31) computeShortestPath();
}

vector<int> Answer() {
    vector<int> ans;
    for(int i = 0; i < N; i++){
        ans.push_back(dist[i]);
    }
    return ans;
}

Compilation message

Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:59:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = cur.size()-31; i < cur.size()-22; i++){
                                    ~~^~~~~~~~~~~~~~~
Azer.cpp:63:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = cur.size()-22; i < cur.size()-11; i++){
                                    ~~^~~~~~~~~~~~~~~
Azer.cpp:67:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = cur.size()-11; i < cur.size(); i++){
                                    ~~^~~~~~~~~~~~
Azer.cpp:73:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(cur.size() == B * 31) computeShortestPath();
        ~~~~~~~~~~~^~~~~~~~~

Baijan.cpp: In function 'void ReceiveA(bool)':
Baijan.cpp:61:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = cur.size()-31; i < cur.size()-22; i++){
                                    ~~^~~~~~~~~~~~~~~
Baijan.cpp:65:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = cur.size()-22; i < cur.size()-11; i++){
                                    ~~^~~~~~~~~~~~~~~
Baijan.cpp:69:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = cur.size()-11; i < cur.size(); i++){
                                    ~~^~~~~~~~~~~~
Baijan.cpp:75:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(cur.size() == B * 31) computeShortestPath();
        ~~~~~~~~~~~^~~~~~~~~
/tmp/ccTBJaHa.o: In function `main':
grader_baijan.cpp:(.text.startup+0x163): undefined reference to `InitB(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
grader_baijan.cpp:(.text.startup+0x1df): undefined reference to `ReceiveB(bool)'
collect2: error: ld returned 1 exit status