#include <bits/stdc++.h>
#include "Azer.h"
using namespace std;
typedef long long int ll;
namespace {
int n;
vector<pair<int,int>> graf[2009];
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> djikstra;
int dst[2009];
int wczyt=0,ter=0;
pair<int,int> cel;
int nr=0;
int last=0;
void napisz(int x, int cnt){
for (int i=0;i<cnt;i++) SendA(x & (1<<i));
}
void nast(int v, int d){
//if (nr<10) cout << "A:" << v << ' ' << d << '\n';
dst[v] = d;
last = d;
for (pair<int,int> x:graf[v]){
if (dst[x.first] > d+x.second){
djikstra.push({d+x.second,x.first});
}
}
while(!djikstra.empty() && dst[djikstra.top().second] < 1e9) djikstra.pop();
if (djikstra.empty()){
djikstra.push({(1<<20)-1+last,0});
//if (nr<10) cout << "A empty\n";
}
//if (nr<10) cout << "A->B " << djikstra.top().second << ' ' << djikstra.top().first-last << '\n';
napisz(djikstra.top().second,11);
napisz(djikstra.top().first-last,9);
nr++;
}
} // namespace
void InitA(int N, int A, vector<int> U, vector<int> V,
vector<int> C) {
n = N;
for (int x=0;x<A;x++){
graf[U[x]].push_back({V[x],C[x]});
graf[V[x]].push_back({U[x],C[x]});
}
for (int x=0;x<=n;x++) dst[x] = 1e9+9;
nast(0,0);
cel = {-1,-1};
}
void ReceiveA(bool x) {
wczyt += (1<<ter) * x;
ter++;
if (ter==11){
cel.first = wczyt;
wczyt = 0;
ter = 0;
}
if (ter==9 && cel.first != -1){
if (djikstra.top().first >= (1<<20)-1 && wczyt == (1<<9)-1) return;
cel.second = wczyt+last;
//if (nr<10) cout << "A ma:" << djikstra.top().first << ' ' << djikstra.top().second << '\n';
//if (nr<10) cout << "A dostalo: " << cel.first << ' ' << cel.second << '\n';
//if (nr<10) cout << "A twierdzi o empt: " << apuste << ' ' << bpuste << '\n';
if (min(djikstra.top().first,cel.second) >= (1<<20)-1) return;
if (djikstra.top().first <= cel.second){
cel.second = djikstra.top().first;
cel.first = djikstra.top().second;
djikstra.pop();
//if (nr<10) cout << "hi\n";
}
nast(cel.first,cel.second);
cel = {-1,-1};
ter = 0;
wczyt = 0;
}
}
vector<int> Answer() {
vector<int> odp;
for (int x=0;x<n;x++) odp.push_back(dst[x]);
return odp;
}
#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
namespace {
int n;
vector<pair<int,int>> graf[2009];
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> djikstra;
int dst[2009];
int wczyt=0,ter=0;
pair<int,int> cel;
pair<int,int> wczes;
int nr=0;
int last=0;
void napisz(int x, int cnt){
for (int i=0;i<cnt;i++) SendB(x & (1<<i));
}
void nast(int v, int d){
//if (nr<10) cout << "B:" << v << ' ' << d << '\n';
dst[v] = d;
last = d;
//if (nr<10) cout << "lelum " << poprz << ' ' << d << '\n';
for (pair<int,int> x:graf[v]){
if (dst[x.first] > d+x.second){
djikstra.push({d+x.second,x.first});
}
}
while(!djikstra.empty() && dst[djikstra.top().second] < 1e9) djikstra.pop();
if (djikstra.empty()){
djikstra.push({(1<<20)-1+last,0});
}
//if (nr<10) cout << "B->A " << djikstra.top().second << ' ' << djikstra.top().first-last << '\n';
napisz(djikstra.top().second,11);
napisz(djikstra.top().first-last,9);
nr++;
}
} // namespace
void InitB(int N, int B, vector<int> S, vector<int> T,
vector<int> D) {
n = N;
for (int x=0;x<B;x++){
graf[T[x]].push_back({S[x],D[x]});
graf[S[x]].push_back({T[x],D[x]});
}
for (int x=0;x<=n;x++) dst[x] = 1e9+9;
cel = {-1,-1};
wczes = {0,0};
djikstra.push({0,0});
}
void ReceiveB(bool y) {
wczyt += (1<<ter) * y;
ter++;
if (ter==11){
//if (nr<10) cout << "B jestem debilem: " << poprz << '\n';
cel.first = wczyt;
ter = 0;
wczyt = 0;
}
if (ter==9 && cel.first != -1){
nast(wczes.first,wczes.second);
if (djikstra.top().first >= (1<<20)-1 && wczyt == (1<<9)-1) return;
cel.second = wczyt+last;
//if (nr<10) cout << "B ma: " << djikstra.top().first << ' ' << djikstra.top().second << '\n';
//if (nr<10) cout << "B dostalo: " << cel.first << ' ' << cel.second << '\n';
if (min(djikstra.top().first,cel.second) >= (1<<20)-1) return;
//if (nr<10) cout << "nr 2: " << apuste << ' ' << bpuste << '\n';
if (djikstra.top().first < cel.second){
cel.second = djikstra.top().first;
cel.first = djikstra.top().second;
djikstra.pop();
}
wczes = cel;
cel = {-1,-1};
wczyt = 0;
ter = 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
230 ms |
332 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
712 KB |
Output is correct |
2 |
Runtime error |
222 ms |
412 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
177 ms |
328 KB |
Wrong Answer [2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
700 KB |
Output is correct |
2 |
Correct |
264 ms |
720 KB |
Output is correct |
3 |
Correct |
349 ms |
13436 KB |
Output is correct |
4 |
Correct |
268 ms |
656 KB |
Output is correct |
5 |
Correct |
344 ms |
10116 KB |
Output is correct |
6 |
Correct |
172 ms |
700 KB |
Output is correct |
7 |
Correct |
240 ms |
728 KB |
Output is correct |
8 |
Correct |
266 ms |
724 KB |
Output is correct |
9 |
Correct |
406 ms |
19492 KB |
Output is correct |
10 |
Correct |
406 ms |
19632 KB |
Output is correct |
11 |
Correct |
599 ms |
38392 KB |
Output is correct |
12 |
Correct |
419 ms |
36044 KB |
Output is correct |
13 |
Correct |
271 ms |
656 KB |
Output is correct |
14 |
Correct |
2 ms |
656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
700 KB |
Output is correct |
2 |
Correct |
264 ms |
720 KB |
Output is correct |
3 |
Correct |
349 ms |
13436 KB |
Output is correct |
4 |
Correct |
268 ms |
656 KB |
Output is correct |
5 |
Correct |
344 ms |
10116 KB |
Output is correct |
6 |
Correct |
172 ms |
700 KB |
Output is correct |
7 |
Correct |
240 ms |
728 KB |
Output is correct |
8 |
Correct |
266 ms |
724 KB |
Output is correct |
9 |
Correct |
406 ms |
19492 KB |
Output is correct |
10 |
Correct |
406 ms |
19632 KB |
Output is correct |
11 |
Correct |
599 ms |
38392 KB |
Output is correct |
12 |
Correct |
419 ms |
36044 KB |
Output is correct |
13 |
Correct |
271 ms |
656 KB |
Output is correct |
14 |
Correct |
2 ms |
656 KB |
Output is correct |
15 |
Correct |
301 ms |
696 KB |
Output is correct |
16 |
Correct |
318 ms |
724 KB |
Output is correct |
17 |
Correct |
202 ms |
720 KB |
Output is correct |
18 |
Correct |
319 ms |
10136 KB |
Output is correct |
19 |
Correct |
294 ms |
712 KB |
Output is correct |
20 |
Correct |
385 ms |
10312 KB |
Output is correct |
21 |
Correct |
314 ms |
744 KB |
Output is correct |
22 |
Correct |
320 ms |
744 KB |
Output is correct |
23 |
Correct |
496 ms |
22412 KB |
Output is correct |
24 |
Correct |
499 ms |
22452 KB |
Output is correct |
25 |
Correct |
702 ms |
44184 KB |
Output is correct |
26 |
Correct |
575 ms |
40544 KB |
Output is correct |
27 |
Correct |
314 ms |
884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
700 KB |
Output is correct |
2 |
Correct |
264 ms |
720 KB |
Output is correct |
3 |
Correct |
349 ms |
13436 KB |
Output is correct |
4 |
Correct |
268 ms |
656 KB |
Output is correct |
5 |
Correct |
344 ms |
10116 KB |
Output is correct |
6 |
Correct |
172 ms |
700 KB |
Output is correct |
7 |
Correct |
240 ms |
728 KB |
Output is correct |
8 |
Correct |
266 ms |
724 KB |
Output is correct |
9 |
Correct |
406 ms |
19492 KB |
Output is correct |
10 |
Correct |
406 ms |
19632 KB |
Output is correct |
11 |
Correct |
599 ms |
38392 KB |
Output is correct |
12 |
Correct |
419 ms |
36044 KB |
Output is correct |
13 |
Correct |
271 ms |
656 KB |
Output is correct |
14 |
Correct |
2 ms |
656 KB |
Output is correct |
15 |
Correct |
301 ms |
696 KB |
Output is correct |
16 |
Correct |
318 ms |
724 KB |
Output is correct |
17 |
Correct |
202 ms |
720 KB |
Output is correct |
18 |
Correct |
319 ms |
10136 KB |
Output is correct |
19 |
Correct |
294 ms |
712 KB |
Output is correct |
20 |
Correct |
385 ms |
10312 KB |
Output is correct |
21 |
Correct |
314 ms |
744 KB |
Output is correct |
22 |
Correct |
320 ms |
744 KB |
Output is correct |
23 |
Correct |
496 ms |
22412 KB |
Output is correct |
24 |
Correct |
499 ms |
22452 KB |
Output is correct |
25 |
Correct |
702 ms |
44184 KB |
Output is correct |
26 |
Correct |
575 ms |
40544 KB |
Output is correct |
27 |
Correct |
314 ms |
884 KB |
Output is correct |
28 |
Correct |
442 ms |
704 KB |
Output is correct |
29 |
Correct |
360 ms |
656 KB |
Output is correct |
30 |
Correct |
542 ms |
24088 KB |
Output is correct |
31 |
Correct |
412 ms |
656 KB |
Output is correct |
32 |
Correct |
518 ms |
21044 KB |
Output is correct |
33 |
Correct |
405 ms |
736 KB |
Output is correct |
34 |
Correct |
373 ms |
764 KB |
Output is correct |
35 |
Correct |
351 ms |
792 KB |
Output is correct |
36 |
Correct |
556 ms |
24932 KB |
Output is correct |
37 |
Correct |
530 ms |
24968 KB |
Output is correct |
38 |
Correct |
790 ms |
49344 KB |
Output is correct |
39 |
Correct |
750 ms |
46984 KB |
Output is correct |
40 |
Correct |
450 ms |
928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
230 ms |
332 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |