답안 #983607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
983607 2024-05-15T18:56:21 Z Zbyszek99 Two Transportations (JOI19_transportations) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "Azer.h"
#define ff first 
#define ss second
using namespace std;

struct Compare {
    bool operator()(pair<int,int> a, pair<int,int> b) {
        return a > b; 
    }
};

int GETTING_VAL= 0;
int GETTING_V = 1;

vector<int> ans;
int n,m;
vector<pair<int,int>> graf[2001];
bitset<2001> odw;
priority_queue<pair<int,int>, vector<pair<int,int>>, Compare> pri; pri;
int akt_odl;
int akt_oper;
int how_many_bits;
int num;
int new_v;
int tryb;

void SendNum(int x, int wiel)
{
    for(int bit = 0; bit < wiel; bit++)
    {
        if(x & (1 << bit))
        {
            SendA(1);
        }
        else
        {
            SendA(0);
        }
    }
}

void InitA(int N, int M, vector<int> U, vector<int> V, vector<int> cost)
{
    odw[0] = 1;
    ans[0] = 0;
    n = N;
    m = M;
    for(int i = 0; i < m; i++)
    {
        graf[U[i]].push_back({cost[i],V[i]});
        graf[V[i]].push_back({cost[i],U[i]});
    }
    for(auto& it: graf[0])
    {
        pri.push(it);
    }
    pair<int,int> t = pri.top();
    SendNum(t.ff - akt_odl,9)
}

void ReceiveA(bool x)
{
    if(tryb == GETTING_VAL)
    {
        if(x) num += (1 << how_many_bits);
        how_many_bits++;
        if(how_many_bits == 9)
        {
            oper++;
            if(oper == n-1) return;
            if(pri.top().ff - akt_odl <= num)
            {
                SendNum(pri.top().ss,11);
                akt_odl = pri.top().ff;
                ans[pri.top().ff] = akt_odl;
                for(auto& it: graf[pri.top().ss])
                {
                    if(odw[it.ss] == 0) 
                    {
                        pri.push({it.ff + akt_odl, it.ss});
                        odw[it.ss] = 1;
                    }
                }
                how_many_bit = 0;
                num = 0;
                pri.pop();
                SendNum(pri.top().ff - akt_odl,9); //only for Azer
            }
            else
            {
                new_v = 0;
                how_many_bits = 0;
                tryb = GETTING_V;
            }
        }
    }
    else
    {
        if(x) new_v += (1 << how_many_bits);
        how_many_bits++;
        if(how_many_bits == 11)
        {
            tryb = GETTING_VAL;
            ans[new_v] = akt_odl+num;
            akt_odl += num;
            odw[new_v] = 1;
            for(auto& it: graf[new_v])
            {
                if(odw[it.ss] == 0) 
                {
                    pri.push({it.ff + akt_odl, it.ss});
                    odw[it.ss] = 1;
                }
            }
            how_many_bits = 0;
            num = 0;
        }
    }
}

vector<int> Answer()
{
    return ans;
}
#include <bits/stdc++.h>
#include "Baijan.h"
#define ff first 
#define ss second
using namespace std;

struct Compare {
    bool operator()(pair<int,int> a, pair<int,int> b) {
        return a > b; 
    }
};

int GETTING_VAL= 0;
int GETTING_V = 1;

vector<int> ans;
int n,m;
vector<pair<int,int>> graf[2001];
bitset<2001> odw;
priority_queue<pair<int,int>, vector<pair<int,int>>, Compare> pri;
int akt_odl;
int akt_oper;
int how_many_bits;
int num;
int new_v;
int tryb;

void SendNum(int x, int wiel)
{
    for(int bit = 0; bit < wiel; bit++)
    {
        if(x & (1 << bit))
        {
            SendB(1);
        }
        else
        {
            SendB(0);
        }
    }
}

void InitB(int N, int M, vector<int> U, vector<int> V, vector<int> cost)
{
    odw[0] = 1;
    ans[0] = 0;
    n = N;
    m = M;
    for(int i = 0; i < m; i++)
    {
        graf[U[i]].push_back({cost[i],V[i]});
        graf[V[i]].push_back({cost[i],U[i]});
    }
    for(auto& it: graf[0])
    {
        pri.push(it);
    }
    pair<int,int> t = pri.top();
    SendNum(t.ff - akt_odl,9)
}

void ReceiveB(bool x)
{
    if(tryb == GETTING_VAL)
    {
        if(x) num += (1 << how_many_bits);
        how_many_bits++;
        if(how_many_bits == 9)
        {
            oper++;
            if(oper == n-1) return;
            if(pri.top().ff - akt_odl <= num)
            {
                SendNum(pri.top().ss,11);
                akt_odl = pri.top().ff;
                ans[pri.top().ff] = akt_odl;
                for(auto& it: graf[pri.top().ss])
                {
                    if(odw[it.ss] == 0) 
                    {
                        pri.push({it.ff + akt_odl, it.ss});
                        odw[it.ss] = 1;
                    }
                }
                how_many_bit = 0;
                num = 0;
                pri.pop();
               // SendNum(pri.top().ff - akt_odl,9); //only for Azer
            }
            else
            {
                new_v = 0;
                how_many_bits = 0;
                tryb = GETTING_V;
            }
        }
    }
    else
    {
        if(x) new_v += (1 << how_many_bits);
        how_many_bits++;
        if(how_many_bits == 11)
        {
            tryb = GETTING_VAL;
            ans[new_v] = akt_odl+num;
            akt_odl += num;
            odw[new_v] = 1;
            for(auto& it: graf[new_v])
            {
                if(odw[it.ss] == 0) 
                {
                    pri.push({it.ff + akt_odl, it.ss});
                    odw[it.ss] = 1;
                }
            }
            how_many_bits = 0;
            num = 0;
        }
    }
}

Compilation message

Azer.cpp:20:68: error: 'pri' does not name a type
   20 | priority_queue<pair<int,int>, vector<pair<int,int>>, Compare> pri; pri;
      |                                                                    ^~~
Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:59:30: error: expected ';' before '}' token
   59 |     SendNum(t.ff - akt_odl,9)
      |                              ^
      |                              ;
   60 | }
      | ~                             
Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:70:13: error: 'oper' was not declared in this scope
   70 |             oper++;
      |             ^~~~
Azer.cpp:85:17: error: 'how_many_bit' was not declared in this scope; did you mean 'how_many_bits'?
   85 |                 how_many_bit = 0;
      |                 ^~~~~~~~~~~~
      |                 how_many_bits

Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:59:30: error: expected ';' before '}' token
   59 |     SendNum(t.ff - akt_odl,9)
      |                              ^
      |                              ;
   60 | }
      | ~                             
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:70:13: error: 'oper' was not declared in this scope
   70 |             oper++;
      |             ^~~~
Baijan.cpp:85:17: error: 'how_many_bit' was not declared in this scope; did you mean 'how_many_bits'?
   85 |                 how_many_bit = 0;
      |                 ^~~~~~~~~~~~
      |                 how_many_bits