답안 #985857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985857 2024-05-19T07:41:05 Z SzymonKrzywda Two Transportations (JOI19_transportations) C++17
0 / 100
141 ms 12536 KB
#include <bits/stdc++.h>
#include "Azer.h"

using namespace std;

namespace{
const int BITS = 20;
int liczba_w;
int akt = 0;
int akt_2 = 0;
string akt_str = "";
vector<int> answer={};
int info[3];
vector<vector<pair<int,int>>> graf(500000);


void dijkstra(){
    int val,v,b,val_2;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq;
    pq.push({0,0});
    while (!pq.empty()){
        val = pq.top().first;
        v = pq.top().second;
        //cout << "V: " << v << " VAl: " << val << endl;
        pq.pop();
        if (val >= answer[v]) continue;
        answer[v] = val;
        for (int i=0; i<graf[v].size(); i++){
            b = graf[v][i].first;
            val_2 = graf[v][i].second;
            pq.push({val+val_2,b});
        }
    }
}
string decToBinary(int n)
{
    string ans = "";
    for (int i = BITS; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            ans += "1";
        else
            ans += "0";
    }
    return ans;
}

int binaryToDecimal(string str)
{
    int dec_num = 0;
    int power = 0 ;
    int n = str.length() ;

      for(int i = n-1 ; i>=0 ; i--){
      if(str[i] == '1'){
        dec_num += (1<<power) ;
      }
      power++ ;
    }

    return dec_num;
}


void send(int a){
    int c=a;
    string bin = decToBinary(a);
    for (int i=0; i<BITS+1; i++){
        SendA(bin[i]);
    }
}

}
void ReceiveA(bool x){
    /*
    //cout << x << " " << akt_2 << endl;
    if (x == 0) akt_str += "0";
    else akt_str += "1";

    if (akt_2==BITS){

    int liczba = binaryToDecimal(akt_str);
    //cout << "LICZBA: " << liczba << endl;

        if (akt==0){ // wierzcholek 1
            info[0] = liczba;
        }
        else if (akt==1){// wierzcholek 2
            info[1] = liczba;
        }
        else{ // waga
            graf[info[0]].push_back({info[1],liczba});
            graf[info[1]].push_back({info[0],liczba});
            //out << info[0] << info[1] << liczba << endl;
        }
        akt_2 = 0;
        akt = (akt+1)%3;
        akt_str = "";
    }
    else akt_2 += 1;
        */
}

void SendA(bool y);


void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C){
    for (int i=0; i<N; i++){
        answer.push_back(9999999);
    }
    for (int i=0; i<A; i++){
        graf[U[i]].push_back({V[i],C[i]});
        graf[V[i]].push_back({U[i],C[i]});
    }

}

vector<int> Answer(){
    //cout << "HALO";
    dijkstra();
    //cout << "HALO";
    return answer;
}
#include <bits/stdc++.h>
#include "Baijan.h"
using namespace std;

namespace{
const int BITS = 20;

string decToBinary(int n)
{
    string ans = "";
    for (int i = BITS; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            ans += "1";
        else
            ans += "0";
    }
    return ans;
}


void send(int a){
    int c=a;
    string bin = decToBinary(a);
    //cout << "BIN: " << bin << endl;
    for (int i=0; i<BITS+1; i++){
        //cout << "BIT: " << bin[i]-'0' << endl;
        SendB(bin[i]-'0');
    }
}
}
void ReceiveB(bool y){

}

void SendB(bool x);

void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D){
    //cout << "HI";
    for (int i=0; i<B; i++){
        send(S[i]);
        send(T[i]);
        send(D[i]);
    }
    //cout << "DWWD";

}

Compilation message

Azer.cpp: In function 'void {anonymous}::dijkstra()':
Azer.cpp:28:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (int i=0; i<graf[v].size(); i++){
      |                       ~^~~~~~~~~~~~~~~
Azer.cpp: In function 'void {anonymous}::send(int)':
Azer.cpp:66:9: warning: unused variable 'c' [-Wunused-variable]
   66 |     int c=a;
      |         ^
Azer.cpp: At global scope:
Azer.cpp:65:6: warning: 'void {anonymous}::send(int)' defined but not used [-Wunused-function]
   65 | void send(int a){
      |      ^~~~
Azer.cpp:48:5: warning: 'int {anonymous}::binaryToDecimal(std::string)' defined but not used [-Wunused-function]
   48 | int binaryToDecimal(string str)
      |     ^~~~~~~~~~~~~~~
Azer.cpp:13:5: warning: '{anonymous}::info' defined but not used [-Wunused-variable]
   13 | int info[3];
      |     ^~~~
Azer.cpp:10:5: warning: '{anonymous}::akt_2' defined but not used [-Wunused-variable]
   10 | int akt_2 = 0;
      |     ^~~~~
Azer.cpp:9:5: warning: '{anonymous}::akt' defined but not used [-Wunused-variable]
    9 | int akt = 0;
      |     ^~~
Azer.cpp:8:5: warning: '{anonymous}::liczba_w' defined but not used [-Wunused-variable]
    8 | int liczba_w;
      |     ^~~~~~~~

Baijan.cpp: In function 'void {anonymous}::send(int)':
Baijan.cpp:23:9: warning: unused variable 'c' [-Wunused-variable]
   23 |     int c=a;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 12108 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12440 KB Output is correct
2 Runtime error 7 ms 12108 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 12108 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 141 ms 12536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 141 ms 12536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 141 ms 12536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 12108 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -