#include "Azer.h"
#include <bits/stdc++.h>
#define iii tuple<int, int, int>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
namespace {
int N, A;
vector<pii> g[2000];
vector<int> d;
int step, val;
int ns, nid;
int u, v, w;
void dijkstra() {
priority_queue<pii, vector<pii>, greater<pii> > Q;
Q.emplace(d[0] = 0, 0);
while(!Q.empty()) {
auto u = Q.top(); Q.pop();
if(u.x != d[u.y]) continue;
for(auto v : g[u.y]) if(d[v.x] > d[u.y] + v.y)
Q.emplace(d[v.x] = d[u.y] + v.y, v.x);
}
}
}
void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C) {
SendA(A ? true : false);
::N = N, ::A = A;
d.resize(N, (1 << 20) - 1);
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) {
if(step <= 18) {
if(x) val |= 1 << step;
step++;
} else {
if(A) {
if(ns < 12) { if(x) u |= 1 << ns; }
else if(ns < 24) { if(x) v |= 1 << (ns-12); }
else { if(x) w |= 1 << (ns-24); }
if(++ns == 33) {
nid++;
g[u].emplace_back(v, w), g[v].emplace_back(u, w);
u = v = w = ns = 0;
}
if(nid == val) dijkstra();
} else {
if(x) w |= 1 << ns;
if(++ns == 20) {
d[nid++] = w;
w = ns = 0;
}
}
}
}
vector<int> Answer() {
return d;
}
#include "Baijan.h"
#include <bits/stdc++.h>
#define iii tuple<int, int, int>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
namespace {
int N;
int count;
int val;
int step, nid, ns;
int u, v, w;
vector<iii> E;
vector<pii> g[2000];
vector<int> d;
void dijkstra() {
priority_queue<pii, vector<pii>, greater<pii> > Q;
Q.emplace(d[0] = 0, 0);
while(!Q.empty()) {
auto u = Q.top(); Q.pop();
if(u.x != d[u.y]) continue;
for(auto v : g[u.y]) if(d[v.x] > d[u.y] + v.y)
Q.emplace(d[v.x] = d[u.y] + v.y, v.x);
}
}
}
void InitB(int N, int B, vector<int> S, vector<int> T, vector<int> D) {
for(int i = 0; i <= 18; ++i) SendB(B >> i & 1);
::N = N;
d.resize(N, (1<<20) - 1);
for(int i = 0; i < B; ++i) {
E.emplace_back(S[i], T[i], D[i]);
g[S[i]].emplace_back(T[i], D[i]);
g[T[i]].emplace_back(S[i], D[i]);
}
}
void ReceiveB(bool y) {
if(y) {
for(auto x : E) {
int u, v, w; tie(u, v, w) = x;
for(int i = 0; i < 12; ++i) SendB(u >> i & 1);
for(int i = 0; i < 12; ++i) SendB(v >> i & 1);
for(int i = 0; i < 9; ++i) SendB(w >> i & 1);
}
} else {
dijkstra();
for(int i = 0; i < N; ++i) {
for(int j = 0; j < 20; ++j) SendB(d[i] >> j & 1);
}
}
}
Compilation message
Baijan.cpp:14:13: warning: '{anonymous}::w' defined but not used [-Wunused-variable]
int u, v, w;
^
Baijan.cpp:14:10: warning: '{anonymous}::v' defined but not used [-Wunused-variable]
int u, v, w;
^
Baijan.cpp:14:7: warning: '{anonymous}::u' defined but not used [-Wunused-variable]
int u, v, w;
^
Baijan.cpp:13:18: warning: '{anonymous}::ns' defined but not used [-Wunused-variable]
int step, nid, ns;
^~
Baijan.cpp:13:13: warning: '{anonymous}::nid' defined but not used [-Wunused-variable]
int step, nid, ns;
^~~
Baijan.cpp:13:7: warning: '{anonymous}::step' defined but not used [-Wunused-variable]
int step, nid, ns;
^~~~
Baijan.cpp:12:7: warning: '{anonymous}::val' defined but not used [-Wunused-variable]
int val;
^~~
Baijan.cpp:11:7: warning: '{anonymous}::count' defined but not used [-Wunused-variable]
int count;
^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
420 ms |
1680 KB |
Output is correct |
2 |
Correct |
4 ms |
1088 KB |
Output is correct |
3 |
Correct |
622 ms |
1560 KB |
Output is correct |
4 |
Correct |
697 ms |
25096 KB |
Output is correct |
5 |
Correct |
33 ms |
1984 KB |
Output is correct |
6 |
Correct |
564 ms |
5464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1224 KB |
Output is correct |
2 |
Correct |
512 ms |
1912 KB |
Output is correct |
3 |
Correct |
342 ms |
1912 KB |
Output is correct |
4 |
Correct |
752 ms |
54856 KB |
Output is correct |
5 |
Incorrect |
413 ms |
48240 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
436 ms |
1760 KB |
Output is correct |
2 |
Correct |
8 ms |
1248 KB |
Output is correct |
3 |
Correct |
606 ms |
2032 KB |
Output is correct |
4 |
Correct |
312 ms |
1912 KB |
Output is correct |
5 |
Correct |
448 ms |
1808 KB |
Output is correct |
6 |
Correct |
476 ms |
1568 KB |
Output is correct |
7 |
Correct |
188 ms |
1648 KB |
Output is correct |
8 |
Incorrect |
12 ms |
964 KB |
Wrong Answer [2] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
170 ms |
1248 KB |
Output is correct |
2 |
Correct |
414 ms |
1648 KB |
Output is correct |
3 |
Incorrect |
130 ms |
13164 KB |
Wrong Answer [2] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
170 ms |
1248 KB |
Output is correct |
2 |
Correct |
414 ms |
1648 KB |
Output is correct |
3 |
Incorrect |
130 ms |
13164 KB |
Wrong Answer [2] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
170 ms |
1248 KB |
Output is correct |
2 |
Correct |
414 ms |
1648 KB |
Output is correct |
3 |
Incorrect |
130 ms |
13164 KB |
Wrong Answer [2] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
420 ms |
1680 KB |
Output is correct |
2 |
Correct |
4 ms |
1088 KB |
Output is correct |
3 |
Correct |
622 ms |
1560 KB |
Output is correct |
4 |
Correct |
697 ms |
25096 KB |
Output is correct |
5 |
Correct |
33 ms |
1984 KB |
Output is correct |
6 |
Correct |
564 ms |
5464 KB |
Output is correct |
7 |
Correct |
6 ms |
1224 KB |
Output is correct |
8 |
Correct |
512 ms |
1912 KB |
Output is correct |
9 |
Correct |
342 ms |
1912 KB |
Output is correct |
10 |
Correct |
752 ms |
54856 KB |
Output is correct |
11 |
Incorrect |
413 ms |
48240 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |