이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Azer.h"
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef struct {
int to;
int w;
} edge_t;
namespace {
int N;
bool rd_directly;
int bit_idx = 0;
vector<bool> bits;
vector< vector<edge_t> > vts;
bool read_bool() {
return bits[bit_idx++];
}
int read_int(int b) {
int x = 0;
for (int i = 0; i < b; i++) {
x += ((int) read_bool()) << i;
}
return x;
}
} // namespace
void InitA(int N, int A, std::vector<int> U, std::vector<int> V,
std::vector<int> C) {
::N = N;
rd_directly = (A==0);
SendA(A==0);
for (int i = 0; i < N; i++) {
vector<edge_t> tmp;
vts.push_back(tmp);
}
for (int i = 0; i < A; i++) {
vts[U[i]].push_back({.to = V[i], .w = C[i]});
vts[V[i]].push_back({.to = U[i], .w = C[i]});
}
}
void ReceiveA(bool x) {
bits.push_back(x);
}
std::vector<int> Answer() {
vector<int> ans(N,2000000000);
if (rd_directly) {
for (int i = 0; i < N; i++) {
ans[i] = read_int(20);
}
return ans;
}
while (bit_idx < bits.size()) {
int u = read_int(11);
int v = read_int(11);
int c = read_int(9);
vts[u].push_back({.to = v, .w = c});
vts[v].push_back({.to = u, .w = c});
}
ans[0] = 0;
auto cmp = [](edge_t a, edge_t b){
return a.w>b.w;
};
vector<bool> visited(N, false);
priority_queue<edge_t, vector<edge_t>, decltype(cmp)> queue(cmp);
queue.push({.to=0, .w=0});
while (!queue.empty()) {
edge_t e = queue.top();
queue.pop();
if (visited[e.to]) continue;
visited[e.to] = true;
ans[e.to] = e.w;
for (edge_t e2 : vts[e.to]) {
// if (visited[e2.to]) continue;
e2.w += e.w;
queue.push(e2);
}
}
return ans;
}
#include "Baijan.h"
#include <vector>
#include <queue>
using namespace std;
typedef struct {
int to;
int w;
} edge_t;
namespace {
int N;
vector< vector<edge_t> > vts;
int B;
std::vector<int> S;
std::vector<int> T;
std::vector<int> D;
// int count;
// bool FunctionExample(bool P) {
// return !P;
// }
void send_int(int x, int b) {
for (int i = 0; i < b; i++) {
SendB((x>>i)&1);
}
}
} // namespace
void InitB(int N, int B, std::vector<int> S, std::vector<int> T,
std::vector<int> D) {
::N = N;
::B = B;
::S = S;
::T = T;
::D = D;
// count = 0;
}
void ReceiveB(bool y) {
if (y) {
for (int i = 0; i < N; i++) {
vector<edge_t> tmp;
vts.push_back(tmp);
}
for (int i = 0; i < B; i++) {
vts[S[i]].push_back({.to = T[i], .w = D[i]});
vts[T[i]].push_back({.to = S[i], .w = D[i]});
}
vector<int> ans(N,2000000000);
ans[0] = 0;
auto cmp = [](edge_t a, edge_t b){
return a.w>b.w;
};
vector<bool> visited(N, false);
priority_queue<edge_t, vector<edge_t>, decltype(cmp)> queue(cmp);
queue.push({.to=0, .w=0});
while (!queue.empty()) {
edge_t e = queue.top();
queue.pop();
if (visited[e.to]) continue;
visited[e.to] = true;
ans[e.to] = e.w;
for (edge_t e2 : vts[e.to]) {
// if (visited[e2.to]) continue;
e2.w += e.w;
queue.push(e2);
}
}
for (int i = 0; i < N; i++) {
send_int(ans[i], 20);
}
} else {
for (int i = 0; i < B; i++) {
send_int(S[i], 11);
send_int(T[i], 11);
send_int(D[i], 9);
};
}
// ++count;
// if (count < 58000) {
// SendB(FunctionExample(y));
// ++count;
// }
}
컴파일 시 표준 에러 (stderr) 메시지
Azer.cpp: In function 'std::vector<int> Answer()':
Azer.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | while (bit_idx < bits.size()) {
| ~~~~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |