답안 #708232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708232 2023-03-11T11:00:48 Z alvingogo Two Transportations (JOI19_transportations) C++14
0 / 100
280 ms 904 KB
#include <bits/stdc++.h>
#include "Azer.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;


namespace{
    vector<int> dis;
    int n;
    int m;
    vector<vector<pair<int,int> > > gg;
    int nw,f=-1,r=-1,c=-1;
    int cnt=0;
    int flag=-1;
    int z=0;
}
void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C){
    n=N;
    m=A;
    gg.resize(n);
    dis.resize(n,1e9);
    for(int i=0;i<m;i++){
        gg[U[i]].push_back({V[i],C[i]});
        gg[V[i]].push_back({V[i],C[i]});
    }
}

void ReceiveA(bool x){
    if(flag==-1){
        flag=x;
        return;
    }
    nw=nw*2+x;
    cnt++;
    if(flag==0){
        if(cnt==20){
            dis[z]=nw;
            nw=0;
            cnt=0;
            z++;
        }
    }
    else{
        if(cnt==11){
            if(f==-1){
                f=nw;
            }
            else if(r==-1){
                r=nw;
            }
            else if(c==-1){
                c=nw;
                gg[f].push_back({r,c});
                gg[r].push_back({f,c});
                f=-1;
                r=-1;
                c=-1;
            }
            cnt=0;
            nw=0;
        }
    }
}

std::vector<int> Answer(){
    if(flag){
        p_q<pair<int,int> > pq;
        pq.push({0,0});
        while(pq.size()){
            auto h=pq.top();
            pq.pop();
            h.fs*=-1;
            if(h.fs!=dis[h.sc]){
                continue;
            }
            for(auto y:gg[h.sc]){
                if(dis[y.fs]>h.fs+y.sc){
                    dis[y.fs]=h.fs+y.sc;
                    pq.push({-dis[y.fs],y.fs});
                }
            }
        }
    }
    return dis;
}
#include <bits/stdc++.h>
#include "Baijan.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

void send(int a,int i){
    i--;
    for(;i>=0;i--){
        SendB((a>>i)&1);
    }
}
void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D){
    if(B<=1000){
        SendB(1);
        for(int i=0;i<B;i++){
            send(S[i],11);
            send(T[i],11);
            send(D[i],11);
        }
    }
    else{
        SendB(0);
        vector<int> dis(N,1e9);
        vector<vector<pair<int,int> > > gg(N);
        for(int i=0;i<B;i++){
            gg[S[i]].push_back({T[i],D[i]});
            gg[T[i]].push_back({T[i],D[i]});
        }
        p_q<pair<int,int> > pq;
        pq.push({0,0});
        while(pq.size()){
            auto h=pq.top();
            pq.pop();
            h.fs*=-1;
            if(h.fs!=dis[h.sc]){
                continue;
            }
            for(auto y:gg[h.sc]){
                if(dis[y.fs]>h.fs+y.sc){
                    dis[y.fs]=h.fs+y.sc;
                    pq.push({-dis[y.fs],y.fs});
                }
            }
        }
        for(int i=0;i<N;i++){
            send(dis[i],20);
        }
    }
}
void ReceiveB(bool y){

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 266 ms 788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 280 ms 904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 142 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 142 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 142 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 266 ms 788 KB Output isn't correct
2 Halted 0 ms 0 KB -