This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "grader.h"
#include "encoder.h"
using namespace std;
int dis[1001][37];
vector<int>adj[1001];
void reset(int n, int h){
for(int i = 0; i < n; i++){
adj[i].clear();
for(int j = 0; j < h; j++) dis[i][j] = INT_MAX;
}
}
void encode(int n, int h, int p, int a[], int b[]){
reset(n,h);
for(int i = 0; i < p; i++){
adj[a[i]].push_back(b[i]);
adj[b[i]].push_back(a[i]);
}
for(int i = 0; i < h; i++){
dis[i][i] = 0;
set<pair<int,int>>bfs;
bfs.insert({0,i});
while(bfs.size()){
auto x = *bfs.begin();
bfs.erase(x);
if(dis[x.second][i] < x.first) continue;
for(auto s:adj[x.second]){
if(dis[x.second][i] + 1 < dis[s][i]){
dis[s][i] = dis[x.second][i]+ 1;
bfs.insert({dis[x.second][i] + 1, s});
}
}
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < h; j++){
for(int k = 0; k < 10; k++){
if(dis[i][j] & (1 << k)) encode_bit(1);
else encode_bit(0);
}
}
}
}
#include<bits/stdc++.h>
#include "grader.h"
#include "decoder.h"
using namespace std;
int dis[1001][37];
void reset(int n, int h){
for(int i = 0; i < n; i++){
for(int j = 0; j < h; j++) dis[i][j] = 1e18;
}
}
void decode(int n, int h){
reset(n,h);
for(int i = 0; i < n; i++){
for(int j = 0; j < h; j++){
if(dis[j][i] != 1e18){
dis[i][j] = dis[j][i];
continue;
}
dis[i][j] = 0;
for(int k = 0; k < 10; k++){
if(decode_bit()){
dis[i][j] += (1 << k);
}
}
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < h; j++){
hops(j,i,dis[i][j]);
}
}
}
Compilation message (stderr)
decoder.cpp: In function 'void reset(int, int)':
decoder.cpp:10:48: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
10 | for(int j = 0; j < h; j++) dis[i][j] = 1e18;
| ^~~~
# | 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... |